fix unchecked integer multiplication overflow 1080/head
authorsetharnold <seth.arnold@gmail.com>
Thu, 15 Feb 2018 01:46:38 +0000 (17:46 -0800)
committerGitHub <noreply@github.com>
Thu, 15 Feb 2018 01:46:38 +0000 (17:46 -0800)
Hello, this fixes an unchecked integer multiplication overflow. Thanks.

src/lib/openjp2/image.c

index 13bcb8e45f69149fcb7063b6226de07b7b6f2d2f..fe37390534a9a3f8dae5c845c1b248361044d9a7 100644 (file)
@@ -48,8 +48,8 @@ opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts,
         image->color_space = clrspc;
         image->numcomps = numcmpts;
         /* allocate memory for the per-component information */
-        image->comps = (opj_image_comp_t*)opj_calloc(1,
-                       image->numcomps * sizeof(opj_image_comp_t));
+        image->comps = (opj_image_comp_t*)opj_calloc(image->numcomps,
+                       sizeof(opj_image_comp_t));
         if (!image->comps) {
             /* TODO replace with event manager, breaks API */
             /* fprintf(stderr,"Unable to allocate memory for image.\n"); */