Prevent resource leak during screenshot
Using RAII would be a better solution, but it requires non-trivial code refactor in this area.
This commit is contained in:
parent
0d71bf0ea4
commit
f3f33c5ea1
1 changed files with 9 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue