diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2009-12-11 21:49:30 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2009-12-11 21:49:30 +0000 |
commit | a0b468f5db92daf1854c49d920169ed39e9cfb1b (patch) | |
tree | c00848c82b6780ddcf51dc095f591f8b0fddebe8 /libavcodec/avpacket.c | |
parent | 15a316c0146106ac627fa67ddaa639f75a4eccce (diff) | |
download | ffmpeg-a0b468f5db92daf1854c49d920169ed39e9cfb1b.tar.gz |
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
Diffstat (limited to 'libavcodec/avpacket.c')
-rw-r--r-- | libavcodec/avpacket.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 5bea639d66..5a80325388 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -47,18 +47,20 @@ void av_init_packet(AVPacket *pkt) int av_new_packet(AVPacket *pkt, int size) { - uint8_t *data; - if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE) - return AVERROR(ENOMEM); + uint8_t *data= NULL; + if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE) data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); - if (!data) - return AVERROR(ENOMEM); + if (data){ memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + }else + size=0; av_init_packet(pkt); pkt->data = data; pkt->size = size; pkt->destruct = av_destruct_packet; + if(!data) + return AVERROR(ENOMEM); return 0; } |