terminate buf properly (\r\n -> \n translation can cause the bytes read to

be /much/ smaller than expected)
This commit is contained in:
Bill Currie 2004-02-05 00:13:42 +00:00
parent f4e0147345
commit 22fe9de3f9

View file

@ -569,13 +569,15 @@ LoadMapFile (const char *filename)
{ {
char *buf; char *buf;
QFile *file; QFile *file;
int bytes;
file = Qopen (filename, "rt"); file = Qopen (filename, "rt");
if (!file) if (!file)
Sys_Error ("couldn't open %s. %s", filename, strerror(errno)); Sys_Error ("couldn't open %s. %s", filename, strerror(errno));
buf = malloc (Qfilesize (file) + 1); bytes = Qfilesize (file);
buf[Qfilesize (file)] = 0; buf = malloc (bytes + 1);
Qread (file, buf, Qfilesize (file)); bytes = Qread (file, buf, bytes);
buf[bytes] = 0;
Qclose (file); Qclose (file);
script_file = filename; script_file = filename;