gsdx:png: Fix accidental resource leak

Oops.

Unfortunately it'll reintroduce the clobbering warning on gcc 4.9.
This commit is contained in:
Jonathan Li 2016-12-12 23:00:43 +00:00
parent b178423166
commit 61669d1f3f
1 changed files with 3 additions and 2 deletions

View File

@ -59,6 +59,7 @@ namespace GSPng {
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
png_infop info_ptr = nullptr; png_infop info_ptr = nullptr;
bool success = false;
try { try {
if (png_ptr == nullptr) if (png_ptr == nullptr)
throw GSDXRecoverableError(); throw GSDXRecoverableError();
@ -89,16 +90,16 @@ namespace GSPng {
} }
png_write_end(png_ptr, nullptr); png_write_end(png_ptr, nullptr);
success = true;
} catch (GSDXRecoverableError&) { } catch (GSDXRecoverableError&) {
fprintf(stderr, "Failed to write image %s\n", file.c_str()); fprintf(stderr, "Failed to write image %s\n", file.c_str());
return false;
} }
if (png_ptr) if (png_ptr)
png_destroy_write_struct(&png_ptr, info_ptr ? &info_ptr : nullptr); png_destroy_write_struct(&png_ptr, info_ptr ? &info_ptr : nullptr);
fclose(fp); fclose(fp);
return true; return success;
} }
bool Save(GSPng::Format fmt, const string& file, uint8* image, int w, int h, int pitch, int compression, bool rb_swapped) bool Save(GSPng::Format fmt, const string& file, uint8* image, int w, int h, int pitch, int compression, bool rb_swapped)