summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormayeut <mayeut@users.noreply.github.com>2015-09-23 21:17:06 +0200
committermayeut <mayeut@users.noreply.github.com>2015-09-23 21:17:06 +0200
commitf82d7f3a63a99997449b15390d0c3f2fc6159d9c (patch)
treed467cfab76ab5aa7a7ebdaa8a46f417e56f8fa8c /src
parentfaf63fddad6efab9fa4dcb14cd290766722a7eec (diff)
Use buffer on stack to read TGA header
Fixes a potential leak Fixes #601
Diffstat (limited to 'src')
-rw-r--r--src/bin/jp2/convert.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
index a894a369..1ccb34f8 100644
--- a/src/bin/jp2/convert.c
+++ b/src/bin/jp2/convert.c
@@ -573,7 +573,7 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
unsigned int *width, unsigned int *height, int *flip_image)
{
int palette_size;
- unsigned char *tga ;
+ unsigned char tga[TGA_HEADER_SIZE];
unsigned char id_len, /*cmap_type,*/ image_type;
unsigned char pixel_depth, image_desc;
unsigned short /*cmap_index,*/ cmap_len, cmap_entry_size;
@@ -581,7 +581,6 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
if (!bits_per_pixel || !width || !height || !flip_image)
return 0;
- tga = (unsigned char*)malloc(18);
if ( fread(tga, TGA_HEADER_SIZE, 1, fp) != 1 )
{
@@ -605,8 +604,6 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
pixel_depth = (unsigned char)tga[16];
image_desc = (unsigned char)tga[17];
- free(tga);
-
*bits_per_pixel = (unsigned int)pixel_depth;
*width = (unsigned int)image_w;
*height = (unsigned int)image_h;