]> granicus.if.org Git - openjpeg/commitdiff
Fix UBSan gcc warning for first arg to memset non null
authorJulien Malik <julien.malik@paraiso.me>
Mon, 2 May 2016 10:13:24 +0000 (12:13 +0200)
committerJulien Malik <julien.malik@paraiso.me>
Mon, 2 May 2016 10:13:24 +0000 (12:13 +0200)
src/lib/openjp2/t1.c

index 1e9480bd9ed69159f166b9af79555267a2918782..1bf7205e9886069f3bc026d412ac4928d4436593 100644 (file)
@@ -1180,7 +1180,10 @@ static OPJ_BOOL opj_t1_allocate_buffers(
                        }
                        t1->datasize=datasize;
                }
-               memset(t1->data,0,datasize * sizeof(OPJ_INT32));
+               /* memset first arg is declared to never be null by gcc */
+               if (t1->data != NULL) {
+                       memset(t1->data,0,datasize * sizeof(OPJ_INT32));
+               }
        }
        t1->flags_stride=w+2;
        flagssize=t1->flags_stride * (h+2);