Merge pull request #1185 from Young-X/fix
[openjpeg.git] / src / lib / openjp2 / image.c
index bf7a70194279b43af359a059c73a031d858273e1..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"); */
@@ -70,7 +70,7 @@ opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts,
             comp->sgnd = cmptparms[compno].sgnd;
             if (comp->h != 0 &&
                     (OPJ_SIZE_T)comp->w > SIZE_MAX / comp->h / sizeof(OPJ_INT32)) {
-                // TODO event manager
+                /* TODO event manager */
                 opj_image_destroy(image);
                 return NULL;
             }