mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-05-28 07:29:14 +00:00
Check for OOM after av_mallocz() in ff_interleave_add_packet().
Fixes a crash with the sample from Ubuntu bug #869125.
This commit is contained in:
parent
8a3f976498
commit
4d7c71c364
3 changed files with 20 additions and 7 deletions
|
@ -3262,12 +3262,14 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
|
||||
int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
|
||||
int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
|
||||
{
|
||||
AVPacketList **next_point, *this_pktl;
|
||||
|
||||
this_pktl = av_mallocz(sizeof(AVPacketList));
|
||||
if (!this_pktl)
|
||||
return AVERROR(ENOMEM);
|
||||
this_pktl->pkt= *pkt;
|
||||
pkt->destruct= NULL; // do not free original but only the copy
|
||||
av_dup_packet(&this_pktl->pkt); // duplicate the packet if it uses non-alloced memory
|
||||
|
@ -3296,6 +3298,7 @@ next_non_null:
|
|||
|
||||
s->streams[pkt->stream_index]->last_in_packet_buffer=
|
||||
*next_point= this_pktl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacket *pkt)
|
||||
|
@ -3314,10 +3317,12 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk
|
|||
AVPacketList *pktl;
|
||||
int stream_count=0, noninterleaved_count=0;
|
||||
int64_t delta_dts_max = 0;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
if(pkt){
|
||||
ff_interleave_add_packet(s, pkt, ff_interleave_compare_dts);
|
||||
ret = ff_interleave_add_packet(s, pkt, ff_interleave_compare_dts);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for(i=0; i < s->nb_streams; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue