From 329c6637d8a1dc05e5f3d3d32f8a00522458ecc9 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Wed, 24 Oct 2007 17:20:29 +0000 Subject: [PATCH] * Check malloc's return value * Don't perform assertions on the content of uninitialized memory, it's useless and annoying when they fail git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2615 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/framework/tagfile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/framework/tagfile.c b/lib/framework/tagfile.c index ab7300b00..601d5d7a3 100644 --- a/lib/framework/tagfile.c +++ b/lib/framework/tagfile.c @@ -209,9 +209,17 @@ static bool init(const char *definition, const char *datafile, bool write) fsize = PHYSFS_fileLength(fp); assert(fsize > 0); + buffer = bufptr = malloc(fsize + 1); + if (!buffer || !bufptr) + { + debug(LOG_ERROR, __FILE__ ":init(): Out of memory"); + abort(); + return false; + } + bufptr[fsize] = '\0'; // ensure it is zero terminated - assert(*bufptr != 0); + fsize2 = PHYSFS_read(fp, bufptr, 1, fsize); if (fsize != fsize2) {