library: Fix FAT load function

"rb+" isn't required, "rb" is more correct.

Also, it is important to check the result of fread().
This commit is contained in:
Antonio Niño Díaz 2023-11-11 18:34:21 +00:00
parent a4c1b40c7a
commit 95e6a16a89

View File

@ -10,7 +10,7 @@
char *NE_FATLoadData(const char *filename)
{
FILE *f = fopen(filename, "rb+");
FILE *f = fopen(filename, "rb");
if (f == NULL)
{
NE_DebugPrint("%s could't be opened", filename);
@ -28,7 +28,12 @@ char *NE_FATLoadData(const char *filename)
return NULL;
}
fread(buffer, 1, size, f);
if (fread(buffer, 1, size, f) != size)
{
NE_DebugPrint("Failed to read data of %s", filename);
return NULL;
}
fclose(f);
return buffer;
}