Mercurial > libavcodec.hg
changeset 10673:158f0ea08e82 libavcodec
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.
author | michael |
---|---|
date | Fri, 11 Dec 2009 21:49:30 +0000 |
parents | 2aab93afc826 |
children | f04468776158 |
files | avpacket.c |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/avpacket.c Thu Dec 10 23:06:23 2009 +0000 +++ b/avpacket.c Fri Dec 11 21:49:30 2009 +0000 @@ -47,18 +47,20 @@ 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; }