Skip to content

Commit

Permalink
Fix Coverity #155476: potential resource leak
Browse files Browse the repository at this point in the history
If the reading of GD2 images fails due to a truncated file, we have to
make sure that all resources are freed. We do so by going to `fail`
instead of bailing out early.

This is a minor issue, though, as GD2 isn't recommended for production
use at all.
  • Loading branch information
cmb69 committed Jan 30, 2017
1 parent acc1104 commit e65415d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/gd_gd2.c
Expand Up @@ -509,15 +509,13 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
if (im->trueColor) {
if (!gdGetInt (&im->tpixels[y][x], in)) {
gd_error("gd2: EOF while reading\n");
gdImageDestroy(im);
return NULL;
goto fail;
}
} else {
int ch;
if (!gdGetByte (&ch, in)) {
gd_error("gd2: EOF while reading\n");
gdImageDestroy(im);
return NULL;
goto fail;
}
im->pixels[y][x] = ch;
}
Expand Down

0 comments on commit e65415d

Please sign in to comment.