From 6468bb4f9b1ca75e7c546c9da2a9897e8fce4872 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 10 Aug 2022 14:31:34 +0100 Subject: [PATCH] Fix documentation omission around mosquitto_reinitialise. Closes #2489. Thanks to rroguski --- ChangeLog.txt | 1 + include/mosquitto.h | 7 ++++--- lib/mosquitto.c | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 975fb8a1..f84d38c9 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -27,6 +27,7 @@ Client library: - Fix incorrect use of SSL_connect. Closes #2594. - Don't set SIGPIPE to ignore, use MSG_NOSIGNAL instead. Closes #2564. - Add documentation of struct mosquitto_message to header. Closes #2561. +- Fix documentation omission around mosquitto_reinitialise. Closes #2489. Clients: - Fix mosquitto_pub incorrectly reusing topic aliases when reconnecting. diff --git a/include/mosquitto.h b/include/mosquitto.h index a169ab7f..1c860ac8 100644 --- a/include/mosquitto.h +++ b/include/mosquitto.h @@ -346,9 +346,10 @@ libmosq_EXPORT void mosquitto_destroy(struct mosquitto *mosq); * callbacks that are specified. * * Returns: - * MOSQ_ERR_SUCCESS - on success. - * MOSQ_ERR_INVAL - if the input parameters were invalid. - * MOSQ_ERR_NOMEM - if an out of memory condition occurred. + * MOSQ_ERR_SUCCESS - on success. + * MOSQ_ERR_INVAL - if the input parameters were invalid. + * MOSQ_ERR_NOMEM - if an out of memory condition occurred. + * MOSQ_ERR_MALFORMED_UTF8 - if the client id is not valid UTF-8. * * See Also: * , diff --git a/lib/mosquitto.c b/lib/mosquitto.c index 9f23adfd..27a44c15 100644 --- a/lib/mosquitto.c +++ b/lib/mosquitto.c @@ -163,6 +163,9 @@ int mosquitto_reinitialise(struct mosquitto *mosq, const char *id, bool clean_st return MOSQ_ERR_MALFORMED_UTF8; } mosq->id = mosquitto__strdup(id); + if(!mosq->id){ + return MOSQ_ERR_NOMEM; + } } mosq->in_packet.payload = NULL; packet__cleanup(&mosq->in_packet);