summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormayeut <mayeut@users.noreply.github.com>2015-09-23 21:20:11 +0200
committermayeut <mayeut@users.noreply.github.com>2015-09-23 21:20:11 +0200
commit09c35dcb84c56699318973a6cbc9eb31f64a0e18 (patch)
treef399e67c10a8412427dfd3799b708d24d9a550b0 /src
parent3ea4486bedf15be988736e6f9cb5db088ea9017c (diff)
parentf82d7f3a63a99997449b15390d0c3f2fc6159d9c (diff)
Merge branch 'master' into travis-matrix
Diffstat (limited to 'src')
-rw-r--r--src/bin/jp2/convert.c5
-rw-r--r--src/bin/jp2/convertbmp.c4
-rw-r--r--src/lib/openjp2/j2k.c13
3 files changed, 13 insertions, 9 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;
diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c
index 1131a599..0678d9d3 100644
--- a/src/bin/jp2/convertbmp.c
+++ b/src/bin/jp2/convertbmp.c
@@ -572,7 +572,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
- *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
+ *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
}
}
else { /* absolute mode */
@@ -598,7 +598,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride
if((j&1) == 0) {
c1 = (OPJ_UINT8)getc(IN);
}
- *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
+ *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
}
if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */
getc(IN);
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index d487d89d..f7a1d764 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -8603,8 +8603,10 @@ static opj_codestream_index_t* opj_j2k_create_cstr_index(void)
cstr_index->marknum = 0;
cstr_index->marker = (opj_marker_info_t*)
opj_calloc(cstr_index->maxmarknum, sizeof(opj_marker_info_t));
- if (!cstr_index-> marker)
+ if (!cstr_index-> marker) {
+ opj_free(cstr_index);
return NULL;
+ }
cstr_index->tile_index = NULL;
@@ -9668,14 +9670,14 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
* so move to the last SOT read */
if ( !(opj_stream_read_seek(p_stream, p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos+2, p_manager)) ){
opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
- opj_free(l_current_data);
+ opj_free(l_current_data);
return OPJ_FALSE;
}
}
else{
if ( !(opj_stream_read_seek(p_stream, p_j2k->cstr_index->tile_index[l_tile_no_to_dec].tp_index[0].start_pos+2, p_manager)) ) {
opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
- opj_free(l_current_data);
+ opj_free(l_current_data);
return OPJ_FALSE;
}
}
@@ -9733,6 +9735,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
/* move into the codestream to the the first SOT (FIXME or not move?)*/
if (!(opj_stream_read_seek(p_stream, p_j2k->cstr_index->main_head_end + 2, p_manager) ) ) {
opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
+ opj_free(l_current_data);
return OPJ_FALSE;
}
break;
@@ -9998,11 +10001,15 @@ OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k,
/* now copy this data into the tile component */
if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,l_current_data,l_current_tile_size)) {
opj_event_msg(p_manager, EVT_ERROR, "Size mismatch between tile data and sent data." );
+ opj_free(l_current_data);
return OPJ_FALSE;
}
}
if (! opj_j2k_post_write_tile (p_j2k,p_stream,p_manager)) {
+ if (l_current_data) {
+ opj_free(l_current_data);
+ }
return OPJ_FALSE;
}
}