]> granicus.if.org Git - curl/commitdiff
memdebug: don't setbuf() if the file open failed
authorGisle Vanem <gisle.vanem@gmail.com>
Thu, 6 Jul 2017 21:14:29 +0000 (23:14 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 6 Jul 2017 21:15:00 +0000 (23:15 +0200)
Bug: https://github.com/curl/curl/issues/828#issuecomment-313475151

lib/memdebug.c

index 2b8808ab03e1f4b0b9e9d16e736b742562e1c063..16434f819ecc5ef2954fb91c7484a7d4a573a5f4 100644 (file)
@@ -115,7 +115,8 @@ void curl_memdebug(const char *logname)
       logfile = stderr;
 #ifdef MEMDEBUG_LOG_SYNC
     /* Flush the log file after every line so the log isn't lost in a crash */
-    setbuf(logfile, (char *)NULL);
+    if(logfile)
+      setbuf(logfile, (char *)NULL);
 #endif
   }
 }