* [FFmpeg-devel] [PATCH] avcodec/mss[12]: Cleanup generically on init failure
@ 2024-02-27 21:29 Andreas Rheinhardt
2024-02-29 9:36 ` Andreas Rheinhardt
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Rheinhardt @ 2024-02-27 21:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mss1.c | 3 ++-
libavcodec/mss2.c | 9 +++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c
index fb5fc34ea1..5460673133 100644
--- a/libavcodec/mss1.c
+++ b/libavcodec/mss1.c
@@ -206,7 +206,7 @@ static av_cold int mss1_decode_init(AVCodecContext *avctx)
ret = ff_mss12_decode_init(&c->ctx, 0, &c->sc, NULL);
if (ret < 0)
- av_frame_free(&c->pic);
+ return ret;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
@@ -233,4 +233,5 @@ const FFCodec ff_mss1_decoder = {
.close = mss1_decode_end,
FF_CODEC_DECODE_CB(mss1_decode_frame),
.p.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 2237cc8bb1..d54a1220b5 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -886,14 +886,10 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx)
c->pal_stride = c->mask_stride;
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 || !ctx->last_pic) {
- mss2_decode_end(avctx);
+ if (!c->pal_pic || !c->last_pal_pic || !ctx->last_pic)
return AVERROR(ENOMEM);
- }
- if (ret = wmv9_init(avctx)) {
- mss2_decode_end(avctx);
+ if (ret = wmv9_init(avctx))
return ret;
- }
ff_mss2dsp_init(&ctx->dsp);
avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555
@@ -913,4 +909,5 @@ const FFCodec ff_mss2_decoder = {
.close = mss2_decode_end,
FF_CODEC_DECODE_CB(mss2_decode_frame),
.p.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/mss[12]: Cleanup generically on init failure
2024-02-27 21:29 [FFmpeg-devel] [PATCH] avcodec/mss[12]: Cleanup generically on init failure Andreas Rheinhardt
@ 2024-02-29 9:36 ` Andreas Rheinhardt
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Rheinhardt @ 2024-02-29 9:36 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/mss1.c | 3 ++-
> libavcodec/mss2.c | 9 +++------
> 2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c
> index fb5fc34ea1..5460673133 100644
> --- a/libavcodec/mss1.c
> +++ b/libavcodec/mss1.c
> @@ -206,7 +206,7 @@ static av_cold int mss1_decode_init(AVCodecContext *avctx)
>
> ret = ff_mss12_decode_init(&c->ctx, 0, &c->sc, NULL);
> if (ret < 0)
> - av_frame_free(&c->pic);
> + return ret;
>
> avctx->pix_fmt = AV_PIX_FMT_PAL8;
>
> @@ -233,4 +233,5 @@ const FFCodec ff_mss1_decoder = {
> .close = mss1_decode_end,
> FF_CODEC_DECODE_CB(mss1_decode_frame),
> .p.capabilities = AV_CODEC_CAP_DR1,
> + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
> };
> diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
> index 2237cc8bb1..d54a1220b5 100644
> --- a/libavcodec/mss2.c
> +++ b/libavcodec/mss2.c
> @@ -886,14 +886,10 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx)
> c->pal_stride = c->mask_stride;
> 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 || !ctx->last_pic) {
> - mss2_decode_end(avctx);
> + if (!c->pal_pic || !c->last_pal_pic || !ctx->last_pic)
> return AVERROR(ENOMEM);
> - }
> - if (ret = wmv9_init(avctx)) {
> - mss2_decode_end(avctx);
> + if (ret = wmv9_init(avctx))
> return ret;
> - }
> ff_mss2dsp_init(&ctx->dsp);
>
> avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555
> @@ -913,4 +909,5 @@ const FFCodec ff_mss2_decoder = {
> .close = mss2_decode_end,
> FF_CODEC_DECODE_CB(mss2_decode_frame),
> .p.capabilities = AV_CODEC_CAP_DR1,
> + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
> };
Will apply this patch tomorrow unless there are objections.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-29 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 21:29 [FFmpeg-devel] [PATCH] avcodec/mss[12]: Cleanup generically on init failure Andreas Rheinhardt
2024-02-29 9:36 ` Andreas Rheinhardt
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git