From d64ca20b313804667bbb4f96a341330e502c427b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 31 Mar 2012 14:18:59 +0000 Subject: [PATCH] - fixed: FileReader::Gets did not check for a lump's end when reading through a WADs file object. SVN r3496 (trunk) --- src/files.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/files.cpp b/src/files.cpp index 332bddb1f..26313e15b 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -145,11 +145,16 @@ long FileReader::Read (void *buffer, long len) char *FileReader::Gets(char *strbuf, int len) { - if (len <= 0) return 0; + if (len <= 0 || FilePos >= Length) return NULL; char *p = fgets(strbuf, len, File); if (p != NULL) { + int old = FilePos; FilePos = ftell(File) - StartPos; + if (FilePos > Length) + { + strbuf[Length-old] = 0; + } } return p; }