]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/parser: Don't return pointer to stack buffer
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 19 Mar 2021 15:02:15 +0000 (16:02 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 20 Mar 2021 02:56:57 +0000 (03:56 +0100)
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.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/parser.c

index f4bc00da7d20db8189635b083f516cfd972ec08c..11c41d6a0a0e20a443d91e040261ecfc87d83b01 100644 (file)
@@ -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;