mss2: prevent potential uninitialized reads
authorAlberto Delmás <adelmas@gmail.com>
Sun, 11 Nov 2012 08:47:39 +0000 (09:47 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 11 Nov 2012 15:07:50 +0000 (16:07 +0100)
The alternative to zeroing on init is setting the corrupted flag in
all cases where pal_pic is not fully written, at the cost of added
complexity.

Signed-off-by: Kostya Shishkov <kostya.shishkov@gmail.com>
libavcodec/mss2.c

index 5f99b7a..bec3f45 100644 (file)
@@ -839,8 +839,8 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx)
     if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1]))
         return ret;
     c->pal_stride   = c->mask_stride;
-    c->pal_pic      = av_malloc(c->pal_stride * avctx->height);
-    c->last_pal_pic = av_malloc(c->pal_stride * avctx->height);
+    c->pal_pic      = av_mallocz(c->pal_stride * avctx->height);
+    c->last_pal_pic = av_mallocz(c->pal_stride * avctx->height);
     if (!c->pal_pic || !c->last_pal_pic) {
         mss2_decode_end(avctx);
         return AVERROR(ENOMEM);