]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mqttd: fclose test file when done
authorDaniel Stenberg <daniel@haxx.se>
Mon, 9 Nov 2020 07:49:59 +0000 (08:49 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 9 Nov 2020 16:25:22 +0000 (17:25 +0100)
Reported-by: Marc Hörsken
Reviewed-by: Jay Satiro
Bug: #6058
Closes #6189

tests/server/mqttd.c

index f0c768ed8c563f6e2a9ed9b04dc6abf7f1df39d3..1f4344ac0bcf2eefa9fa7ece5b2837342d51db70 100644 (file)
@@ -486,6 +486,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
   size_t bytes = 0; /* remaining length field size in bytes */
   char client_id[MAX_CLIENT_ID_LENGTH];
   long testno;
+  FILE *stream = NULL;
 
   static const char protocol[7] = {
     0x00, 0x04,       /* protocol length */
@@ -550,7 +551,6 @@ static curl_socket_t mqttit(curl_socket_t fd)
       }
     }
     else if(byte == MQTT_MSG_SUBSCRIBE) {
-      FILE *stream;
       int error;
       char *data;
       size_t datalen;
@@ -636,7 +636,10 @@ static curl_socket_t mqttit(curl_socket_t fd)
   } while(1);
 
   end:
-  fclose(dump);
+  if(dump)
+    fclose(dump);
+  if(stream)
+    fclose(stream);
   return CURL_SOCKET_BAD;
 }