RagePhoto.c: fix potential memory issue

This commit is contained in:
Syping 2023-06-07 06:12:24 +02:00
parent 24e0d9c03e
commit 6acf7b7338

View file

@ -926,6 +926,10 @@ bool ragephoto_savefilef(ragephoto_t instance_t, const char *filename, uint32_t
#else
FILE *file = fopen(filename, "wb");
#endif
if (!file) {
free(data);
return false;
}
const size_t fileWsize = fwrite(data, sizeof(char), fileSize, file);
fclose(file);
free(data);