diff options
| author | Stefan Weil <sw@weilnetz.de> | 2018-10-31 20:44:30 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@mines-paris.org> | 2018-10-31 20:44:30 +0100 |
| commit | 948332e6ed17565100d1df5f6fdbf66865218e36 (patch) | |
| tree | 8e38306366e69eef4da8827372d00cf2280ee55c /src/lib/openjp2/jp2.c | |
| parent | e52909f4c7896c5efff3340d707c12d0df55d3f9 (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/jp2.c')
| -rw-r--r-- | src/lib/openjp2/jp2.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c index 180a416b..4402ffe3 100644 --- a/src/lib/openjp2/jp2.c +++ b/src/lib/openjp2/jp2.c @@ -1079,7 +1079,7 @@ static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image, /* Palette mapping: */ new_comps[i].data = (OPJ_INT32*) - opj_image_data_alloc(old_comps[cmp].w * old_comps[cmp].h * sizeof(OPJ_INT32)); + opj_image_data_alloc(sizeof(OPJ_INT32) * old_comps[cmp].w * old_comps[cmp].h); if (!new_comps[i].data) { while (i > 0) { -- i; @@ -1193,8 +1193,8 @@ static OPJ_BOOL opj_jp2_read_pclr(opj_jp2_t *jp2, return OPJ_FALSE; } - entries = (OPJ_UINT32*) opj_malloc((size_t)nr_channels * nr_entries * sizeof( - OPJ_UINT32)); + entries = (OPJ_UINT32*) opj_malloc(sizeof(OPJ_UINT32) * nr_channels * + nr_entries); if (!entries) { return OPJ_FALSE; } |
