From 5820e97abe6013d5e20bd8dea9b97990ea457543 Mon Sep 17 00:00:00 2001 From: Luc Hermitte Date: Thu, 23 Aug 2012 19:34:41 +0000 Subject: [PATCH] [trunk] realloc is misused and may leak memory (Issue#168) (complements: compilation errors) --- libopenjpeg/jpwl/jpwl.c | 6 +++--- libopenjpeg/jpwl/jpwl.h | 2 +- libopenjpeg/jpwl/jpwl_lib.c | 2 +- libopenjpeg/t1.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libopenjpeg/jpwl/jpwl.c b/libopenjpeg/jpwl/jpwl.c index 8a5447fb..abbeb2d6 100644 --- a/libopenjpeg/jpwl/jpwl.c +++ b/libopenjpeg/jpwl/jpwl.c @@ -164,7 +164,7 @@ void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) { opj_bool j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) { if (!cstr_info) - return; + return OPJ_FALSE; /* expand the list? */ if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) { @@ -177,8 +177,8 @@ opj_bool j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int typ cstr_info->marker = 0; cstr_info->marknum = 0; cstr_info->maxmarknum = 0; - opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to add a marker\n"); // TODO: find a better error message - TODO_test_add_marker_result; + /* opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory to add a marker\n"); */ + // TODO_test_add_marker_result; return OPJ_FALSE; } cstr_info->marker = new_marker; diff --git a/libopenjpeg/jpwl/jpwl.h b/libopenjpeg/jpwl/jpwl.h index 12076283..52c1fbc2 100644 --- a/libopenjpeg/jpwl/jpwl.h +++ b/libopenjpeg/jpwl/jpwl.h @@ -336,7 +336,7 @@ opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *bu opj_bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf); -void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len); +opj_bool j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len); /** corrects the data in the JPWL codestream @param j2k J2K compressor handle diff --git a/libopenjpeg/jpwl/jpwl_lib.c b/libopenjpeg/jpwl/jpwl_lib.c index 90a71cec..ee01aa05 100644 --- a/libopenjpeg/jpwl/jpwl_lib.c +++ b/libopenjpeg/jpwl/jpwl_lib.c @@ -1581,7 +1581,7 @@ opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) { return OPJ_TRUE; } -void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) { +opj_bool jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) { /* Marker */ *(buf++) = (unsigned char) (J2K_MS_ESD >> 8); diff --git a/libopenjpeg/t1.c b/libopenjpeg/t1.c index becc41a2..298bd445 100644 --- a/libopenjpeg/t1.c +++ b/libopenjpeg/t1.c @@ -1413,7 +1413,7 @@ static opj_bool t1_decode_cblk( cblk->x1 - cblk->x0, cblk->y1 - cblk->y0)) { - return; + return OPJ_FALSE; } bpno = roishift + cblk->numbps - 1; @@ -1757,7 +1757,7 @@ static opj_bool t1_decode_cblk_v2( cblk->x1 - cblk->x0, cblk->y1 - cblk->y0)) { - return; + return OPJ_FALSE; } bpno = roishift + cblk->numbps - 1;