diff mbox series

[FFmpeg-devel] avcodec/rv34: Add check for av_malloc

Message ID 20230417023212.46507-1-jiasheng@iscas.ac.cn
State Accepted
Commit f8d0b13de5fe1a3d158dcc6f419c45c368b1dd4f
Headers show
Series [FFmpeg-devel] avcodec/rv34: Add check for av_malloc | expand

Checks

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

Commit Message

Jiasheng Jiang April 17, 2023, 2:32 a.m. UTC
Add the check for the return value of the av_malloc in order to avoid
NULL pointer deference.

Fixes: b86ab38137 ("Add weighted motion compensation for RV40 B-frames")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 libavcodec/rv34.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

James Almer April 17, 2023, 2:38 a.m. UTC | #1
On 4/16/2023 11:32 PM, Jiasheng Jiang wrote:
> Add the check for the return value of the av_malloc in order to avoid
> NULL pointer deference.
> 
> Fixes: b86ab38137 ("Add weighted motion compensation for RV40 B-frames")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   libavcodec/rv34.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
> index 45f64666f8..51f18147af 100644
> --- a/libavcodec/rv34.c
> +++ b/libavcodec/rv34.c
> @@ -1692,6 +1692,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict,
>               int i;
>   
>               r->tmp_b_block_base = av_malloc(s->linesize * 48);
> +            if (!r->tmp_b_block_base)
> +                return AVERROR(ENOMEM);
>               for (i = 0; i < 2; i++)
>                   r->tmp_b_block_y[i] = r->tmp_b_block_base
>                                         + i * 16 * s->linesize;

Applied, thanks.
diff mbox series

Patch

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 45f64666f8..51f18147af 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1692,6 +1692,8 @@  int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict,
             int i;
 
             r->tmp_b_block_base = av_malloc(s->linesize * 48);
+            if (!r->tmp_b_block_base)
+                return AVERROR(ENOMEM);
             for (i = 0; i < 2; i++)
                 r->tmp_b_block_y[i] = r->tmp_b_block_base
                                       + i * 16 * s->linesize;