From e06774a716e1802d84b7b7defa3fca0d4fafa325 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 8 Jan 2009 13:09:53 +0000 Subject: [PATCH] FS_LoadFile: don't segfault when trying to open a non-regular file git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8635 d7cf8633-e32d-0410-b094-e92efae38249 --- fs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs.c b/fs.c index 12dfc317..4f7baf9d 100644 --- a/fs.c +++ b/fs.c @@ -2517,6 +2517,13 @@ unsigned char *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet, f if (file) { filesize = file->real_length; + if(filesize < 0) + { + Con_Printf("FS_LoadFile(\"%s\", pool, %s, filesizepointer): trying to open a non-regular file\n", path, quiet ? "true" : "false"); + FS_Close(file); + return NULL; + } + buf = (unsigned char *)Mem_Alloc (pool, filesize + 1); buf[filesize] = '\0'; FS_Read (file, buf, filesize); -- 2.39.2