diff --git a/src/hardware/hardware.cpp b/src/hardware/hardware.cpp index 2f800b75..b310d01f 100644 --- a/src/hardware/hardware.cpp +++ b/src/hardware/hardware.cpp @@ -321,14 +321,19 @@ void CAPTURE_AddImage(Bitu width, Bitu height, Bitu bpp, Bitu pitch, Bitu flags, CaptureState &= ~CAPTURE_IMAGE; /* Open the actual file */ - FILE * fp=OpenCaptureFile("Screenshot",".png"); - if (!fp) goto skip_shot; + FILE *fp = OpenCaptureFile("Screenshot", ".png"); + if (!fp) + goto skip_shot; /* First try to allocate the png structures */ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,NULL, NULL); - if (!png_ptr) goto skip_shot; + if (!png_ptr) { + fclose(fp); + goto skip_shot; + } info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_write_struct(&png_ptr,(png_infopp)NULL); + png_destroy_write_struct(&png_ptr, (png_infopp)NULL); + fclose(fp); goto skip_shot; }