aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vstgui/vstgui.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/vstgui/vstgui.cpp b/vstgui/vstgui.cpp
index bf80a82..fe2ef55 100644
--- a/vstgui/vstgui.cpp
+++ b/vstgui/vstgui.cpp
@@ -3755,21 +3755,24 @@ bool CBitmap::openPng (const char* path)
fread(header, 1, 8, fp);
if (png_sig_cmp(header, 0, 8)) {
fprintf(stderr, "File not recognized as a PNG image");
+ fclose(fp);
return false;
}
pngRead = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!pngRead) {
+ if (!pngRead) {
fprintf(stderr, "Unable to initialize libpng\n");
+ fclose(fp);
return false;
}
pngInfo = png_create_info_struct(pngRead);
- if (!pngInfo) {
- png_destroy_read_struct(&pngRead, NULL, NULL);
+ if (!pngInfo) {
+ png_destroy_read_struct(&pngRead, NULL, NULL);
pngRead = NULL;
- return false;
- }
+ fclose(fp);
+ return false;
+ }
png_init_io(pngRead, fp);
png_set_sig_bytes(pngRead, 8);