diff mbox series

[FFmpeg-devel,4/4] avformat/dvdvideodec: Reorder allocations to simplify freeing

Message ID AS8P250MB0744B84930D8EF266EB40B998F5D2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 1a4e0eb3745488e9756495357c6829ecdc45b076
Headers show
Series [FFmpeg-devel,1/4] avformat/dvdvideodec: Explicitly return 0 on success | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt March 2, 2024, 3:43 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/dvdvideodec.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Marth64 March 3, 2024, 2:34 a.m. UTC | #1
Patchset LGTM.

On Sat, Mar 2, 2024 at 9:42 AM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/dvdvideodec.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c
> index f2f23affb2..7f4ecf2b61 100644
> --- a/libavformat/dvdvideodec.c
> +++ b/libavformat/dvdvideodec.c
> @@ -1211,20 +1211,16 @@ static int dvdvideo_subdemux_open(AVFormatContext
> *s)
>      extern const AVInputFormat ff_mpegps_demuxer;
>      int ret = 0;
>
> -    if (!(c->mpeg_ctx = avformat_alloc_context()))
> -        return AVERROR(ENOMEM);
> -
> -    if (!(c->mpeg_buf = av_mallocz(DVDVIDEO_BLOCK_SIZE))) {
> -        avformat_free_context(c->mpeg_ctx);
> -        c->mpeg_ctx = NULL;
> -
> +    if (!(c->mpeg_buf = av_mallocz(DVDVIDEO_BLOCK_SIZE)))
>          return AVERROR(ENOMEM);
> -    }
>
>      ffio_init_context(&c->mpeg_pb, c->mpeg_buf, DVDVIDEO_BLOCK_SIZE, 0, s,
>                        dvdvideo_subdemux_read_data, NULL, NULL);
>      c->mpeg_pb.pub.seekable = 0;
>
> +    if (!(c->mpeg_ctx = avformat_alloc_context()))
> +        return AVERROR(ENOMEM);
> +
>      if ((ret = ff_copy_whiteblacklists(c->mpeg_ctx, s)) < 0) {
>          avformat_free_context(c->mpeg_ctx);
>          c->mpeg_ctx = NULL;
> --
> 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".
>
diff mbox series

Patch

diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c
index f2f23affb2..7f4ecf2b61 100644
--- a/libavformat/dvdvideodec.c
+++ b/libavformat/dvdvideodec.c
@@ -1211,20 +1211,16 @@  static int dvdvideo_subdemux_open(AVFormatContext *s)
     extern const AVInputFormat ff_mpegps_demuxer;
     int ret = 0;
 
-    if (!(c->mpeg_ctx = avformat_alloc_context()))
-        return AVERROR(ENOMEM);
-
-    if (!(c->mpeg_buf = av_mallocz(DVDVIDEO_BLOCK_SIZE))) {
-        avformat_free_context(c->mpeg_ctx);
-        c->mpeg_ctx = NULL;
-
+    if (!(c->mpeg_buf = av_mallocz(DVDVIDEO_BLOCK_SIZE)))
         return AVERROR(ENOMEM);
-    }
 
     ffio_init_context(&c->mpeg_pb, c->mpeg_buf, DVDVIDEO_BLOCK_SIZE, 0, s,
                       dvdvideo_subdemux_read_data, NULL, NULL);
     c->mpeg_pb.pub.seekable = 0;
 
+    if (!(c->mpeg_ctx = avformat_alloc_context()))
+        return AVERROR(ENOMEM);
+
     if ((ret = ff_copy_whiteblacklists(c->mpeg_ctx, s)) < 0) {
         avformat_free_context(c->mpeg_ctx);
         c->mpeg_ctx = NULL;