diff mbox series

[FFmpeg-devel] avcodec/parser: Don't return pointer to stack buffer

Message ID 20210319151615.2323253-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 9faf3f8bb04e537f552332aa316c6659dcd7d251
Headers show
Series [FFmpeg-devel] avcodec/parser: Don't return pointer to stack buffer
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 19, 2021, 3:16 p.m. UTC
When flushing, the parser receives a dummy buffer with padding
that lives on the stack of av_parser_parse2(). Certain parsers
(e.g. Dolby E) only analyze the input, but don't repack it. When
flushing, such parsers return a pointer to the stack buffer and
a size of 0. And this is also what av_parser_parse2() returns.

Fix this by always resetting poutbuf in case poutbuf_size is zero.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
This needs to be applied before 
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-March/278004.html

 libavcodec/parser.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index f4bc00da7d..11c41d6a0a 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -179,6 +179,9 @@  int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
         /* offset of the next frame */
         s->next_frame_offset = s->cur_offset + index;
         s->fetch_timestamp   = 1;
+    } else {
+        /* Don't return a pointer to dummy_buf. */
+        *poutbuf = NULL;
     }
     if (index < 0)
         index = 0;