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.
Unified · Split
| @@ -839,8 +839,8 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) · 838 unmodified lines | |||
| 839 | if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1])) | 839 | if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1])) |
| 840 | return ret; | 840 | return ret; |
| 841 | c->pal_stride = c->mask_stride; | 841 | c->pal_stride = c->mask_stride; |
| 842 | c->pal_pic = av_malloc(c->pal_stride * avctx->height); | 842 | c->pal_pic = av_mallocz(c->pal_stride * avctx->height); |
| 843 | c->last_pal_pic = av_malloc(c->pal_stride * avctx->height); | 843 | c->last_pal_pic = av_mallocz(c->pal_stride * avctx->height); |
| 844 | if (!c->pal_pic || !c->last_pal_pic) { | 844 | if (!c->pal_pic || !c->last_pal_pic) { |
| 845 | mss2_decode_end(avctx); | 845 | mss2_decode_end(avctx); |
| 846 | return AVERROR(ENOMEM); | 846 | return AVERROR(ENOMEM); |