summaryrefslogtreecommitdiff
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorRafaël Carré <funman@videolan.org>2013-06-23 23:00:33 +0200
committerAnton Khirnov <anton@khirnov.net>2013-06-24 08:03:26 +0200
commitc3e58f8fb75d8467161a65b85eb88281547ebab1 (patch)
treea14296ed0a6f2dc3bafdf23e8c9dc9a69494238f /libavformat/matroskaenc.c
parent95d52464542f532061290192518d5fe1c1930e8d (diff)
matroskaenc: restore compatibility with non referenced AVPacket
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 9f7b5f9b52..67d2350afa 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1298,8 +1298,11 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
// keyframe's timecode is contained in the same cluster for WebM
if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
mkv->cur_audio_pkt = *pkt;
- mkv->cur_audio_pkt.buf = av_buffer_ref(pkt->buf);
- ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM);
+ if (pkt->buf) {
+ mkv->cur_audio_pkt.buf = av_buffer_ref(pkt->buf);
+ ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM);
+ } else
+ ret = av_dup_packet(&mkv->cur_audio_pkt);
} else
ret = mkv_write_packet_internal(s, pkt);
return ret;