diff mbox

[FFmpeg-devel,FFmpeg-devel,1/1] avcodec/samidec: check av_strdup() return value

Message ID 1511765792-28805-1-git-send-email-bianpan2016@163.com
State Accepted
Commit 61bbc537ab2305392bd170a6f404ed6402bee4a8
Headers show

Commit Message

Pan Bian Nov. 27, 2017, 6:56 a.m. UTC
In function sami_paragraph_to_ass(), the return value of av_strdup() is
not checked. To avoid potential NULL dereference, the return value
should be checked against NULL.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
V2: fix patcheck warnings
---
 libavcodec/samidec.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Clément Bœsch Nov. 29, 2017, 9:26 p.m. UTC | #1
On Mon, Nov 27, 2017 at 02:56:32PM +0800, Pan Bian wrote:
> In function sami_paragraph_to_ass(), the return value of av_strdup() is
> not checked. To avoid potential NULL dereference, the return value
> should be checked against NULL.
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> V2: fix patcheck warnings
> ---
>  libavcodec/samidec.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c
> index 2620424..6a59806 100644
> --- a/libavcodec/samidec.c
> +++ b/libavcodec/samidec.c
> @@ -48,6 +48,9 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
>      AVBPrint *dst_content = &sami->encoded_content;
>      AVBPrint *dst_source = &sami->encoded_source;
>  
> +    if (!dupsrc)
> +        return AVERROR(ENOMEM);
> +
>      av_bprint_clear(&sami->encoded_content);
>      av_bprint_clear(&sami->content);
>      av_bprint_clear(&sami->encoded_source);

Patch applied, thanks
diff mbox

Patch

diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c
index 2620424..6a59806 100644
--- a/libavcodec/samidec.c
+++ b/libavcodec/samidec.c
@@ -48,6 +48,9 @@  static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
     AVBPrint *dst_content = &sami->encoded_content;
     AVBPrint *dst_source = &sami->encoded_source;
 
+    if (!dupsrc)
+        return AVERROR(ENOMEM);
+
     av_bprint_clear(&sami->encoded_content);
     av_bprint_clear(&sami->content);
     av_bprint_clear(&sami->encoded_source);