From 3c8034609f45a452424c3c515b3da301f140fbde Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 2 Nov 2014 05:36:05 +0000 Subject: [PATCH] Fix a crash I caused with MSVC in OSD_SetLogFile(). Apparently, the behavior of setvbuf() when passed a NULL ptr for a buffer is actually left up to the implementation regarding what it does with the size parameter... DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4718 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/osd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index 0c9bcba34..4cfe65d1c 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -812,16 +812,15 @@ void OSD_SetLogFile(const char *fn) const int bufmode = _IOLBF; #endif - if (osdlog) - { - Bfclose(osdlog); - osdlog = NULL; - } + MAYBE_FCLOSE_AND_NULL(osdlog); - if (fn) osdlog = Bfopen(fn,"w"); + if (!fn) + return; + + osdlog = Bfopen(fn, "w"); if (osdlog) - setvbuf(osdlog, (char *)NULL, bufmode, 0); + setvbuf(osdlog, (char *)NULL, bufmode, BUFSIZ); }