Skip to content

Commit

Permalink
Fix #247, A read out-of-bands was found in the parsing of TGA files (C…
Browse files Browse the repository at this point in the history
  • Loading branch information
oerdnj committed Jul 12, 2016
1 parent 0878ffd commit ead349e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/gd_tga.c
Expand Up @@ -237,7 +237,11 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga )
return -1;
}

gdGetBuf(conversion_buffer, image_block_size, ctx);
if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) {
gd_error("gd-tga: premature end of image data\n");
gdFree(conversion_buffer);
return -1;
}

while (buffer_caret < image_block_size) {
tga->bitmap[buffer_caret] = (int) conversion_buffer[buffer_caret];
Expand All @@ -257,11 +261,16 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga )
}
conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char));
if (conversion_buffer == NULL) {
gd_error("gd-tga: premature end of image data\n");
gdFree( decompression_buffer );
return -1;
}

gdGetBuf( conversion_buffer, image_block_size, ctx );
if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) {
gdFree(conversion_buffer);
gdFree(decompression_buffer);
return -1;
}

buffer_caret = 0;

Expand Down

0 comments on commit ead349e

Please sign in to comment.