HT_DEC: Fix opj_t1_allocate_buffers malloc size error (#1426) (fixes #1413)
authorYuan <zodf0055980@gmail.com>
Tue, 31 May 2022 09:55:12 +0000 (17:55 +0800)
committerGitHub <noreply@github.com>
Tue, 31 May 2022 09:55:12 +0000 (11:55 +0200)
src/lib/openjp2/ht_dec.c

index e2f3afd6a3afa1bcbde535d46fe04abc3f797a7b..a803d1bb378172ff71902a7dedf4e04c58d76bf4 100644 (file)
@@ -1063,7 +1063,7 @@ static OPJ_BOOL opj_t1_allocate_buffers(
         if (flagssize > t1->flagssize) {
 
             opj_aligned_free(t1->flags);
-            t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize);
+            t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize * sizeof(opj_flag_t));
             if (!t1->flags) {
                 /* FIXME event manager error callback */
                 return OPJ_FALSE;
@@ -1071,7 +1071,7 @@ static OPJ_BOOL opj_t1_allocate_buffers(
         }
         t1->flagssize = flagssize;
 
-        memset(t1->flags, 0, flagssize);
+        memset(t1->flags, 0, flagssize * sizeof(opj_flag_t));
     }
 
     t1->w = w;