]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_writeout: check gmtime return code too
authorDaniel Stenberg <daniel@haxx.se>
Fri, 8 Aug 2025 07:24:46 +0000 (09:24 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 8 Aug 2025 09:42:33 +0000 (11:42 +0200)
If the unlikely event happen that it fails, it returns NULL.
CodeSonar is not happy unless we check for it.

Closes #18225

src/tool_writeout.c

index 24697127452a6d1562b2936f5c8b189a90b19510..0a610de79ab1dcc6848bd046b4ce6a30c7e90d0b 100644 (file)
@@ -603,7 +603,7 @@ static const char *outtime(const char *ptr, /* %time{ ... */
     if(!result) {
       /* !checksrc! disable BANNEDFUNC 1 */
       utc = gmtime(&secs);
-      if(curlx_dyn_len(&format) &&
+      if(curlx_dyn_len(&format) && utc &&
          strftime(output, sizeof(output), curlx_dyn_ptr(&format), utc))
         fputs(output, stream);
       curlx_dyn_free(&format);