From 3cbe9227656494166d042456df3bc7d86c4cc54f Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 1 Jan 2021 17:42:08 +0300 Subject: [PATCH] fix UB: fwrite with buffer = NULL --- tools/quake3/common/cmdlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/quake3/common/cmdlib.c b/tools/quake3/common/cmdlib.c index a2045070..7a7c8da2 100644 --- a/tools/quake3/common/cmdlib.c +++ b/tools/quake3/common/cmdlib.c @@ -438,7 +438,7 @@ void SafeRead( FILE *f, void *buffer, int count ){ void SafeWrite( FILE *f, const void *buffer, int count ){ - if ( fwrite( buffer, 1, count, f ) != (size_t)count ) { + if ( buffer != NULL && fwrite( buffer, 1, count, f ) != (size_t)count ) { Error( "File write failure" ); } }