]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/error_resilience.c
aacenc: fix out of array writes
[ffmpeg] / libavcodec / error_resilience.c
index 28cc08fd1beb61514d2c0406d0c737898414ed86..7ddc5ac052383e259033a4d045bc0d366e98a5e4 100644 (file)
@@ -183,6 +183,11 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
     int16_t  (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
     uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
 
+    if(!col || !dist) {
+        av_log(s->avctx, AV_LOG_ERROR, "guess_dc() is out of memory\n");
+        goto fail;
+    }
+
     for(b_y=0; b_y<h; b_y++){
         int color= 1024;
         int distance= -1;
@@ -263,6 +268,8 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
             dc[b_x + b_y * stride] = guess;
         }
     }
+
+fail:
     av_freep(&col);
     av_freep(&dist);
 }
@@ -717,8 +724,6 @@ skip_last_mv:
                         fixed[mb_xy] = MV_UNCHANGED;
                 }
             }
-
-            // printf(".%d/%d", changed, score_sum); fflush(stdout);
         }
 
         if (none_left)
@@ -729,7 +734,6 @@ skip_last_mv:
             if (fixed[mb_xy])
                 fixed[mb_xy] = MV_FROZEN;
         }
-        // printf(":"); fflush(stdout);
     }
 }