Skip to content

Commit

Permalink
avformat/mux: Fix error when writing uncoded frames.
Browse files Browse the repository at this point in the history
commit "avpacket: Deprecate av_dup_packet" broke the use
av_interleaved_write_uncoded_frame as any input uncoded frame has an
invalid packet size that will crash when av_packet_ref tries to allocate
'size' new memory. Since the packet is a temporary created within mux.c
itself it can be used directly without needing a new ref.

Signed-off-by: Matt Oliver <[email protected]>
  • Loading branch information
Sibras committed Jan 27, 2016
1 parent 9079e99 commit b66ac80
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions libavformat/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,15 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
av_assert0(((AVFrame *)pkt->data)->buf);
}

if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) {
av_free(this_pktl);
return ret;
this_pktl->pkt = *pkt;
pkt->buf = NULL;
pkt->side_data = NULL;
pkt->side_data_elems = 0;
} else {
if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) {
av_free(this_pktl);
return ret;
}
}

if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
Expand Down

0 comments on commit b66ac80

Please sign in to comment.