mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
Make sure av_new_packet() initializes the data and destruct pointers.
Some code does call av_free_packet() on failed av_new_packets(), this prevents the freeing of uninitialized pointers. Originally committed as revision 20801 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
15a316c014
commit
a0b468f5db
@ -47,18 +47,20 @@ void av_init_packet(AVPacket *pkt)
|
|||||||
|
|
||||||
int av_new_packet(AVPacket *pkt, int size)
|
int av_new_packet(AVPacket *pkt, int size)
|
||||||
{
|
{
|
||||||
uint8_t *data;
|
uint8_t *data= NULL;
|
||||||
if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
|
if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
if (!data)
|
if (data){
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
}else
|
||||||
|
size=0;
|
||||||
|
|
||||||
av_init_packet(pkt);
|
av_init_packet(pkt);
|
||||||
pkt->data = data;
|
pkt->data = data;
|
||||||
pkt->size = size;
|
pkt->size = size;
|
||||||
pkt->destruct = av_destruct_packet;
|
pkt->destruct = av_destruct_packet;
|
||||||
|
if(!data)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user