* 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-861f7616d084master
parent
e6827605e2
commit
329c6637d8
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue