mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
terminate buf properly (\r\n -> \n translation can cause the bytes read to
be /much/ smaller than expected)
This commit is contained in:
parent
f4e0147345
commit
22fe9de3f9
1 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue