[Ffmpeg-devel] [PATCH] catch OOM in av_interleave_packet_per_dts
Wolfram Gloger
wmglo
Sun Mar 25 16:35:54 CEST 2007
Hi,
This avoids a crash when running out of memory in
av_interleave_packet_per_dts. It also changes av_mallocz to av_malloc
in that location, as all the allocated data is initialized immediately
afterwards.
Regards,
Wolfram
diff -Nur -x .svn trunk/libavformat/utils.c ffmpeg-wg/libavformat/utils.c
--- trunk/libavformat/utils.c 2007-03-23 12:25:32.000000000 +0100
+++ ffmpeg-wg/libavformat/utils.c 2007-03-25 15:03:43.000000000 +0200
@@ -2182,11 +2182,13 @@
int streams[MAX_STREAMS];
if(pkt){
- AVStream *st= s->streams[ pkt->stream_index];
+ const AVStream *st= s->streams[ pkt->stream_index];
// assert(pkt->destruct != av_destruct_packet); //FIXME
- this_pktl = av_mallocz(sizeof(AVPacketList));
+ this_pktl = av_malloc(sizeof(AVPacketList));
+ if(!this_pktl)
+ return -2; // -1 already used up in av_interleaved_write_frame
this_pktl->pkt= *pkt;
if(pkt->destruct == av_destruct_packet)
pkt->destruct= NULL; // non shared -> must keep original from being freed
More information about the ffmpeg-devel
mailing list