]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/tests/integral: Check malloc fail before using it
authorJun Zhao <mypopydev@gmail.com>
Sun, 10 Feb 2019 04:57:44 +0000 (12:57 +0800)
committerJun Zhao <mypopydev@gmail.com>
Tue, 12 Feb 2019 01:08:27 +0000 (09:08 +0800)
Need to check malloc fail before using it, so adjust the location
in the code.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jun Zhao <mypopydev@gmail.com>
libavfilter/tests/integral.c

index 2a8e8ff55f38c13a6492c81de395fc2835c10352..361bfd51e55069f1991b4abdf68c5d9966e4cda0 100644 (file)
@@ -54,6 +54,9 @@ int main(void)
     uint32_t *ii  = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii));
     uint32_t *ii2 = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii2));
 
+    if (!ii || !ii2)
+        return -1;
+
     uint32_t *ii_start  = ii  + ii_lz_32 + 1; // skip top 0-line and left 0-column
     uint32_t *ii_start2 = ii2 + ii_lz_32 + 1; // skip top 0-line and left 0-column
 
@@ -61,9 +64,6 @@ int main(void)
 
     ff_nlmeans_init(&dsp);
 
-    if (!ii || !ii2)
-        return -1;
-
     for (yoff = -e; yoff <= e; yoff++) {
         for (xoff = -e; xoff <= e; xoff++) {
             printf("xoff=%d yoff=%d\n", xoff, yoff);