mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-11 06:58:18 +00:00
avpacket: Fix error checking in packet_alloc
Previously the wrong buffer pointer was checked, when buf instead of *buf was checked. But checking the return value instead is even better. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
6fc8226e29
commit
85e8192b85
@ -64,12 +64,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
|
|
||||||
static int packet_alloc(AVBufferRef **buf, int size)
|
static int packet_alloc(AVBufferRef **buf, int size)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
if ((unsigned)size >= (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
|
if ((unsigned)size >= (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
av_buffer_realloc(buf, size + FF_INPUT_BUFFER_PADDING_SIZE);
|
ret = av_buffer_realloc(buf, size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
if (!buf)
|
if (ret < 0)
|
||||||
return AVERROR(ENOMEM);
|
return ret;
|
||||||
|
|
||||||
memset((*buf)->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
memset((*buf)->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user