avcodec/pafvideo: Cleanup generically on init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
pull/358/head
Andreas Rheinhardt 4 years ago
parent 9227721ef0
commit 7eb9cf593e
  1. 6
      libavcodec/pafvideo.c

@ -104,10 +104,8 @@ static av_cold int paf_video_init(AVCodecContext *avctx)
c->video_size = avctx->width * avctx->height; c->video_size = avctx->width * avctx->height;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
c->frame[i] = av_mallocz(c->frame_size); c->frame[i] = av_mallocz(c->frame_size);
if (!c->frame[i]) { if (!c->frame[i])
paf_video_close(avctx);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
} }
return 0; return 0;
@ -419,5 +417,5 @@ AVCodec ff_paf_video_decoder = {
.close = paf_video_close, .close = paf_video_close,
.decode = paf_video_decode, .decode = paf_video_decode,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
}; };

Loading…
Cancel
Save