summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/t1.c
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2018-10-31 20:44:30 +0100
committerEven Rouault <even.rouault@mines-paris.org>2018-10-31 20:44:30 +0100
commit948332e6ed17565100d1df5f6fdbf66865218e36 (patch)
tree8e38306366e69eef4da8827372d00cf2280ee55c /src/lib/openjp2/t1.c
parente52909f4c7896c5efff3340d707c12d0df55d3f9 (diff)
Fix some potential overflow issues (#1161)
* Fix some potential overflow issues Put sizeof to the beginning of the multiplication to enforce that size_t instead of smaller integer types is used for the calculation. This fixes warnings from LGTM: Multiplication result may overflow 'unsigned int' before it is converted to 'unsigned long'. It also allows removing some type casts. Signed-off-by: Stefan Weil <sw@weilnetz.de> * Fix code indentation Signed-off-by: Stefan Weil <sw@weilnetz.de>
Diffstat (limited to 'src/lib/openjp2/t1.c')
-rw-r--r--src/lib/openjp2/t1.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/openjp2/t1.c b/src/lib/openjp2/t1.c
index 76744380..ec04c682 100644
--- a/src/lib/openjp2/t1.c
+++ b/src/lib/openjp2/t1.c
@@ -1618,8 +1618,8 @@ static void opj_t1_clbl_decode_processor(void* user_data, opj_tls_t* tls)
cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0);
cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0);
- cblk->decoded_data = (OPJ_INT32*)opj_aligned_malloc(cblk_w * cblk_h * sizeof(
- OPJ_INT32));
+ cblk->decoded_data = (OPJ_INT32*)opj_aligned_malloc(sizeof(OPJ_INT32) *
+ cblk_w * cblk_h);
if (cblk->decoded_data == NULL) {
if (job->p_manager_mutex) {
opj_mutex_lock(job->p_manager_mutex);
@@ -1634,7 +1634,7 @@ static void opj_t1_clbl_decode_processor(void* user_data, opj_tls_t* tls)
return;
}
/* Zero-init required */
- memset(cblk->decoded_data, 0, cblk_w * cblk_h * sizeof(OPJ_INT32));
+ memset(cblk->decoded_data, 0, sizeof(OPJ_INT32) * cblk_w * cblk_h);
} else if (cblk->decoded_data) {
/* Not sure if that code path can happen, but better be */
/* safe than sorry */