avcodec/huffyuv: simplify allocation of temporaries
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 19 Feb 2014 19:19:38 +0000 (20:19 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 19 Feb 2014 19:32:02 +0000 (20:32 +0100)
This also fixes a null pointer dereference with rgb and plane prediction

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/huffyuv.c

index 80b35ed..3866535 100644 (file)
@@ -58,17 +58,11 @@ av_cold int ff_huffyuv_alloc_temp(HYuvContext *s)
 {
     int i;
 
-    if (s->bitstream_bpp<24 || s->version > 2) {
-        for (i=0; i<3; i++) {
-            s->temp[i]= av_malloc(2*s->width + 16);
-            if (!s->temp[i])
-                return AVERROR(ENOMEM);
-            s->temp16[i] = (uint16_t*)s->temp[i];
-        }
-    } else {
-        s->temp[0]= av_mallocz(4*s->width + 16);
-        if (!s->temp[0])
+    for (i=0; i<3; i++) {
+        s->temp[i]= av_malloc(4*s->width + 16);
+        if (!s->temp[i])
             return AVERROR(ENOMEM);
+        s->temp16[i] = (uint16_t*)s->temp[i];
     }
     return 0;
 }