fixed bug: Unable to load the empty file (closes #141)

This commit is contained in:
Incont 2015-05-18 18:37:48 +03:00 committed by Shazron Abdullah
parent 1cb6110985
commit c97b972172

View File

@ -1268,7 +1268,7 @@ void* read_file_to_memory(char * path, size_t* file_size)
*file_size = buf.st_size;
FILE* fd = fopen(path, "r");
char* content = malloc(*file_size);
if (fread(content, *file_size, 1, fd) != 1)
if (*file_size != 0 && fread(content, *file_size, 1, fd) != 1)
{
fclose(fd);
return NULL;