Skip to content

Commit

Permalink
Improved ImageFile.cpp (file is now closed on error)
Browse files Browse the repository at this point in the history
  • Loading branch information
randaz81 committed Jan 21, 2025
1 parent 9bcb705 commit 916b4e0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libYARP_sig/src/yarp/sig/ImageFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,22 @@ bool ImageReadRGB_PNG(ImageOf<PixelRgb>& img, const char* filename)
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png)
{
fclose(fp);
yCError(IMAGEFILE) << "PNG internal error";
return false;
}

png_infop info = png_create_info_struct(png);
if (!info)
{
fclose(fp);
yCError(IMAGEFILE) << "PNG internal error";
return false;
}

if (setjmp(png_jmpbuf(png)))
{
fclose(fp);
yCError(IMAGEFILE) << "PNG internal error";
return false;
}
Expand Down

0 comments on commit 916b4e0

Please sign in to comment.