From 22fe9de3f9916739b40de07128a388f2e18d76f3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 5 Feb 2004 00:13:42 +0000 Subject: [PATCH] terminate buf properly (\r\n -> \n translation can cause the bytes read to be /much/ smaller than expected) --- tools/qfbsp/source/map.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/qfbsp/source/map.c b/tools/qfbsp/source/map.c index dc379fae3..d8cbd95a3 100644 --- a/tools/qfbsp/source/map.c +++ b/tools/qfbsp/source/map.c @@ -569,13 +569,15 @@ LoadMapFile (const char *filename) { char *buf; QFile *file; + int bytes; file = Qopen (filename, "rt"); if (!file) Sys_Error ("couldn't open %s. %s", filename, strerror(errno)); - buf = malloc (Qfilesize (file) + 1); - buf[Qfilesize (file)] = 0; - Qread (file, buf, Qfilesize (file)); + bytes = Qfilesize (file); + buf = malloc (bytes + 1); + bytes = Qread (file, buf, bytes); + buf[bytes] = 0; Qclose (file); script_file = filename;