summaryrefslogtreecommitdiffstats
path: root/libavcodec/h2645_parse.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-08-26 00:54:20 -0300
committerJames Almer <jamrial@gmail.com>2019-08-27 10:56:41 -0300
commitaf70bfbeadc0c9b9215cf045ff2a6a31e8ac3a71 (patch)
tree221d22d75aee62f0d206c338664eb3851efb4a5d /libavcodec/h2645_parse.c
parent0821bc4eee25909736efe90616e8afca942c00d5 (diff)
downloadffmpeg-streaming-af70bfbeadc0c9b9215cf045ff2a6a31e8ac3a71.zip
ffmpeg-streaming-af70bfbeadc0c9b9215cf045ff2a6a31e8ac3a71.tar.gz
avcodec/h2645_parse: zero initialize the rbsp buffer
Fixes ticket #8093 Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/h2645_parse.c')
-rw-r--r--libavcodec/h2645_parse.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 24658b3..307e864 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -345,13 +345,18 @@ static int find_next_start_code(const uint8_t *buf, const uint8_t *next_avc)
static void alloc_rbsp_buffer(H2645RBSP *rbsp, unsigned int size, int use_ref)
{
+ int min_size = size;
+
if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
goto fail;
size += AV_INPUT_BUFFER_PADDING_SIZE;
if (rbsp->rbsp_buffer_alloc_size >= size &&
- (!rbsp->rbsp_buffer_ref || av_buffer_is_writable(rbsp->rbsp_buffer_ref)))
+ (!rbsp->rbsp_buffer_ref || av_buffer_is_writable(rbsp->rbsp_buffer_ref))) {
+ av_assert0(rbsp->rbsp_buffer);
+ memset(rbsp->rbsp_buffer + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
return;
+ }
size = FFMIN(size + size / 16 + 32, INT_MAX);
@@ -360,7 +365,7 @@ static void alloc_rbsp_buffer(H2645RBSP *rbsp, unsigned int size, int use_ref)
else
av_free(rbsp->rbsp_buffer);
- rbsp->rbsp_buffer = av_malloc(size);
+ rbsp->rbsp_buffer = av_mallocz(size);
if (!rbsp->rbsp_buffer)
goto fail;
rbsp->rbsp_buffer_alloc_size = size;
OpenPOWER on IntegriCloud