diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2009-02-21 20:57:46 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2009-02-21 20:57:46 +0000 |
commit | c60a0f85eea39542a9b3a5efaf2411abfe2ca528 (patch) | |
tree | 1181a0cf0598de6769efb3e0200e13163ba3f2af | |
parent | 8ebe099ac0c0ca68161c54efc76ea6a7a87f81ce (diff) | |
download | ffmpeg-c60a0f85eea39542a9b3a5efaf2411abfe2ca528.tar.gz |
Check for alloc failures.
Originally committed as revision 17497 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/avidec.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 4a28890407..78e5051e1e 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -718,7 +718,7 @@ resync: if(avi->stream_index >= 0){ AVStream *st= s->streams[ avi->stream_index ]; AVIStream *ast= st->priv_data; - int size; + int size, err; if(ast->sample_size <= 1) // minorityreport.AVI block_align=1024 sample_size=1 IMA-ADPCM size= INT_MAX; @@ -730,14 +730,19 @@ resync: if(size > ast->remaining) size= ast->remaining; avi->last_pkt_pos= url_ftell(pb); - av_get_packet(pb, pkt, size); + err= av_get_packet(pb, pkt, size); + if(err<0) + return err; if(ast->has_pal && pkt->data && pkt->size<(unsigned)INT_MAX/2){ + void *ptr= av_realloc(pkt->data, pkt->size + 4*256 + FF_INPUT_BUFFER_PADDING_SIZE); + if(ptr){ ast->has_pal=0; pkt->size += 4*256; - pkt->data = av_realloc(pkt->data, pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); - if(pkt->data) + pkt->data= ptr; memcpy(pkt->data + pkt->size - 4*256, ast->pal, 4*256); + }else + av_log(s, AV_LOG_ERROR, "Failed to append palette\n"); } if (CONFIG_DV_DEMUXER && avi->dv_demux) { |