Fix small memory leak

This commit is contained in:
2021-04-21 22:14:33 -04:00
parent 3d22a8a73c
commit 8c2ae2a0ab
3 changed files with 6 additions and 2 deletions

View File

@@ -135,7 +135,10 @@ int writePNG(mazegrid_t const* g, char const* filename) {
exit:
if (f != NULL) fclose(f);
if (info_ptr != NULL) png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
if (info_ptr != NULL) {
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
png_destroy_info_struct(png_ptr, &info_ptr);
}
if (png_ptr != NULL) png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
if (img != NULL) freeImageData(img);
return code;