shithub: choc

Download patch

ref: 82257467cbaabfce4db1b4a9f3f349214d3985c6
parent: 40e600b9f4aa8d57ababa3ede02a4e32f56f7c42
author: Fabian Greffrath <[email protected]>
date: Mon Jan 20 17:11:48 EST 2020

explicitly direct output to stdout if '-' is given as a file name

There is no mention in the POSIX documentation that fprintf() will
print to stdout if the NULL pointer is passed as the stream.
And, indeed, the current implementation triggers a segmentation fault
if invoked as '-statdump -'.

--- a/src/doom/statdump.c
+++ b/src/doom/statdump.c
@@ -339,7 +339,7 @@
         }
         else
         {
-            dumpfile = NULL;
+            dumpfile = stdout;
         }
 
         for (i = 0; i < num_captured_stats; ++i)
@@ -347,7 +347,7 @@
             PrintStats(dumpfile, &captured_stats[i]);
         }
 
-        if (dumpfile != NULL)
+        if (dumpfile != stdout)
         {
             fclose(dumpfile);
         }