diff mbox series

[FFmpeg-devel,1/2] avcodec/ralf: Move frame allocation after error checks

Message ID GV1P250MB0737118807137F9A8923CA488F419@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit dcbb7e8a303b4a97b1ff3945277fa1db868ef121
Headers show
Series [FFmpeg-devel,1/2] avcodec/ralf: Move frame allocation after error checks | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 7, 2022, 3:06 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ralf.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Andreas Rheinhardt Sept. 9, 2022, 11:44 p.m. UTC | #1
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/ralf.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
> index 20c5f060d0..8f8e49f535 100644
> --- a/libavcodec/ralf.c
> +++ b/libavcodec/ralf.c
> @@ -451,12 +451,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
>          src_size = avpkt->size;
>      }
>  
> -    frame->nb_samples = ctx->max_frame_size;
> -    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
> -        return ret;
> -    samples0 = (int16_t *)frame->data[0];
> -    samples1 = (int16_t *)frame->data[1];
> -
>      if (src_size < 5) {
>          av_log(avctx, AV_LOG_ERROR, "too short packets are too short!\n");
>          return AVERROR_INVALIDDATA;
> @@ -481,6 +475,11 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
>          ctx->num_blocks++;
>      }
>  
> +    frame->nb_samples = ctx->max_frame_size;
> +    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
> +        return ret;
> +    samples0 = (int16_t *)frame->data[0];
> +    samples1 = (int16_t *)frame->data[1];
>      block_pointer = src      + table_bytes + 2;
>      bytes_left    = src_size - table_bytes - 2;
>      ctx->sample_offset = 0;

Will apply this patchset tonight unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index 20c5f060d0..8f8e49f535 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -451,12 +451,6 @@  static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
         src_size = avpkt->size;
     }
 
-    frame->nb_samples = ctx->max_frame_size;
-    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
-        return ret;
-    samples0 = (int16_t *)frame->data[0];
-    samples1 = (int16_t *)frame->data[1];
-
     if (src_size < 5) {
         av_log(avctx, AV_LOG_ERROR, "too short packets are too short!\n");
         return AVERROR_INVALIDDATA;
@@ -481,6 +475,11 @@  static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
         ctx->num_blocks++;
     }
 
+    frame->nb_samples = ctx->max_frame_size;
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+        return ret;
+    samples0 = (int16_t *)frame->data[0];
+    samples1 = (int16_t *)frame->data[1];
     block_pointer = src      + table_bytes + 2;
     bytes_left    = src_size - table_bytes - 2;
     ctx->sample_offset = 0;