diff --git a/.travis.yml b/.travis.yml index 667ea445..f59c8684 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,6 @@ addons: project: name: "eclipse/mosquitto" description: "Build submitted via Travis CI" - version: notification_email: roger@atchoo.org build_command_prepend: ./travis-configure.sh build_command: "make binary -j 4" diff --git a/client/sub_client.c b/client/sub_client.c index e394d063..fcffbbb6 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -38,7 +38,7 @@ static void write_payload(const unsigned char *payload, int payloadlen, bool hex int i; if(!hex){ - fwrite(payload, 1, payloadlen, stdout); + (void)fwrite(payload, 1, payloadlen, stdout); }else{ for(i=0; iaddress); } send__connack(context, 0, CONNACK_REFUSED_PROTOCOL_VERSION); - mosquitto__free(protocol_name); rc = MOSQ_ERR_PROTOCOL; goto handle_connect_error; } @@ -140,13 +139,11 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context) protocol_version, context->address); } send__connack(context, 0, CONNACK_REFUSED_PROTOCOL_VERSION); - mosquitto__free(protocol_name); rc = MOSQ_ERR_PROTOCOL; goto handle_connect_error; } if((context->in_packet.command&0x0F) != 0x00){ /* Reserved flags not set to 0, must disconnect. */ - mosquitto__free(protocol_name); rc = MOSQ_ERR_PROTOCOL; goto handle_connect_error; } @@ -156,11 +153,11 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context) log__printf(NULL, MOSQ_LOG_INFO, "Invalid protocol \"%s\" in CONNECT from %s.", protocol_name, context->address); } - mosquitto__free(protocol_name); rc = MOSQ_ERR_PROTOCOL; goto handle_connect_error; } mosquitto__free(protocol_name); + protocol_name = NULL; if(packet__read_byte(&context->in_packet, &connect_flags)){ rc = 1; @@ -577,6 +574,7 @@ handle_connect_error: mosquitto__free(will_payload); mosquitto__free(will_topic); mosquitto__free(will_struct); + mosquitto__free(protocol_name); #ifdef WITH_TLS if(client_cert) X509_free(client_cert); #endif diff --git a/src/persist.c b/src/persist.c index 5602d337..d252b786 100644 --- a/src/persist.c +++ b/src/persist.c @@ -635,16 +635,21 @@ static int persist__msg_store_chunk_restore(struct mosquitto_db *db, FILE *db_fp } rc = db__message_store(db, source_id, source_mid, topic, qos, payloadlen, &payload, retain, &stored, store_id); + mosquitto__free(source_id); if(rc == MOSQ_ERR_SUCCESS){ load->db_id = stored->db_id; load->store = stored; HASH_ADD(hh, db->msg_store_load, db_id, sizeof(dbid_t), load); + return MOSQ_ERR_SUCCESS; + }else{ + mosquitto__free(load); + fclose(db_fptr); + mosquitto__free(topic); + UHPA_FREE(payload, payloadlen); + return rc; } - mosquitto__free(source_id); - - return rc; error: strerror_r(errno, err, 256); log__printf(NULL, MOSQ_LOG_ERR, "Error: %s.", err); diff --git a/src/security.c b/src/security.c index 8cae9ec8..b8bcdb37 100644 --- a/src/security.c +++ b/src/security.c @@ -188,6 +188,8 @@ int mosquitto_security_module_cleanup(struct mosquitto_db *db) db->auth_plugins[i].unpwd_check = NULL; db->auth_plugins[i].psk_key_get = NULL; } + mosquitto__free(db->auth_plugins); + db->auth_plugins = NULL; return MOSQ_ERR_SUCCESS; } diff --git a/src/security_default.c b/src/security_default.c index 2be5db13..5fc437b8 100644 --- a/src/security_default.c +++ b/src/security_default.c @@ -131,6 +131,8 @@ int add__acl(struct mosquitto_db *db, const char *user, const char *topic, int a acl = mosquitto__malloc(sizeof(struct mosquitto__acl)); if(!acl){ mosquitto__free(local_topic); + mosquitto__free(acl_user->username); + mosquitto__free(acl_user); return MOSQ_ERR_NOMEM; } acl->access = access; diff --git a/test/lib/c/01-con-discon-success.c b/test/lib/c/01-con-discon-success.c index 9fac2f69..1fbdfd41 100644 --- a/test/lib/c/01-con-discon-success.c +++ b/test/lib/c/01-con-discon-success.c @@ -36,6 +36,8 @@ int main(int argc, char *argv[]) mosquitto_loop(mosq, -1, 1); } + mosquitto_destroy(mosq); + mosquitto_lib_cleanup(); return run; } diff --git a/test/lib/c/01-keepalive-pingreq.c b/test/lib/c/01-keepalive-pingreq.c index 427a5351..99823bc3 100644 --- a/test/lib/c/01-keepalive-pingreq.c +++ b/test/lib/c/01-keepalive-pingreq.c @@ -28,6 +28,7 @@ int main(int argc, char *argv[]) mosquitto_loop(mosq, -1, 1); } + mosquitto_destroy(mosq); mosquitto_lib_cleanup(); return run; }