From 4514036c46168f4bbc693649989d53bdffe6137b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 1 Feb 2010 19:24:22 +0000 Subject: Fix leaks and an iterator error found by cppcheck. git-svn-id: http://svn.drobilla.net/lad/trunk/mda-lv2@2399 a436a847-0d15-0410-975c-d299462d15a1 --- vstgui/vstgui.cpp | 13 ++++++++----- 1 file 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); -- cgit v1.2.1