]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
server/mqttd: fix two memory leaks
authorDaniel Stenberg <daniel@haxx.se>
Mon, 14 Oct 2024 08:21:10 +0000 (10:21 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 14 Oct 2024 10:47:21 +0000 (12:47 +0200)
Closes #15290

tests/server/mqttd.c

index acd53abae6e3d50ee2ca7bfd2eb1d4cd80ee41c1..dc56d99a9e636310872fe54989482322ce1cc570 100644 (file)
@@ -439,6 +439,7 @@ static int publish(FILE *dump,
     loghex(packet, rc);
     logprotocol(FROM_SERVER, "PUBLISH", remaininglength, dump, packet, rc);
   }
+  free(packet);
   if((size_t)rc == packetlen)
     return 0;
   return 1;
@@ -647,13 +648,16 @@ static curl_socket_t mqttit(curl_socket_t fd)
         if(!config.publish_before_suback) {
           if(suback(dump, fd, packet_id)) {
             logmsg("failed sending SUBACK");
+            free(data);
             goto end;
           }
         }
         if(publish(dump, fd, packet_id, topic, data, datalen)) {
           logmsg("PUBLISH failed");
+          free(data);
           goto end;
         }
+        free(data);
         if(config.publish_before_suback) {
           if(suback(dump, fd, packet_id)) {
             logmsg("failed sending SUBACK");