RagePhoto.c: fix potential memory issue
This commit is contained in:
parent
24e0d9c03e
commit
6acf7b7338
1 changed files with 4 additions and 0 deletions
|
@ -926,6 +926,10 @@ bool ragephoto_savefilef(ragephoto_t instance_t, const char *filename, uint32_t
|
||||||
#else
|
#else
|
||||||
FILE *file = fopen(filename, "wb");
|
FILE *file = fopen(filename, "wb");
|
||||||
#endif
|
#endif
|
||||||
|
if (!file) {
|
||||||
|
free(data);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const size_t fileWsize = fwrite(data, sizeof(char), fileSize, file);
|
const size_t fileWsize = fwrite(data, sizeof(char), fileSize, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
free(data);
|
free(data);
|
||||||
|
|
Loading…
Reference in a new issue