opj_compress/opj_uncompress: fix integer overflow in num_images (#1395)
[openjpeg.git] / src / bin / jp2 / opj_compress.c
index 8c71d45367d64b714f2b84e16d6c3d9ccf37fc19..1399d52771e31bee96de2de27b20e94ec82b0309 100644 (file)
@@ -1959,9 +1959,9 @@ int main(int argc, char **argv)
         num_images = get_num_images(img_fol.imgdirpath);
         dirptr = (dircnt_t*)malloc(sizeof(dircnt_t));
         if (dirptr) {
-            dirptr->filename_buf = (char*)malloc(num_images * OPJ_PATH_LEN * sizeof(
+            dirptr->filename_buf = (char*)calloc(num_images, OPJ_PATH_LEN * sizeof(
                     char)); /* Stores at max 10 image file names*/
-            dirptr->filename = (char**) malloc(num_images * sizeof(char*));
+            dirptr->filename = (char**) calloc(num_images, sizeof(char*));
             if (!dirptr->filename_buf) {
                 ret = 0;
                 goto fin;