]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/server: check for `stream != NULL` in mqttd
authorViktor Szakats <commit@vsz.me>
Mon, 12 May 2025 10:33:35 +0000 (12:33 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 12 May 2025 11:16:42 +0000 (13:16 +0200)
To avoid an assert in `fgets()` on MSVC when the test case is missing.

Bug: https://github.com/curl/curl/pull/17294#issuecomment-2867501300

Closes #17324

tests/server/mqttd.c

index 744517077c50a5b9adf9616e36e7f7c4a5e36e61..4fdc67c8afd106e9f0d8fa76f80d9e8dc977da8d 100644 (file)
@@ -583,6 +583,12 @@ static curl_socket_t mqttit(curl_socket_t fd)
 
       logmsg("SUBSCRIBE to '%s' [%d]", topic, packet_id);
       stream = test2fopen(testno, logdir);
+      if(!stream) {
+        error = errno;
+        logmsg("fopen() failed with error (%d) %s", error, strerror(error));
+        logmsg("Couldn't open test file %ld", testno);
+        goto end;
+      }
       error = getpart(&data, &datalen, "reply", "data", stream);
       if(!error) {
         if(!m_config.publish_before_suback) {