diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 78c483c25c..f918d20a61 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -4648,7 +4648,7 @@ void av_packet_free_side_data(AVPacket *pkt); * * @see av_packet_unref * - * @param dst Destination packet + * @param dst Destination packet. Will be completely overwritten. * @param src Source packet * * @return 0 on success, a negative AVERROR on error. diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index b5667659fd..132567bc2d 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -615,6 +615,7 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src) return ret; if (!src->buf) { + dst->buf = NULL; ret = packet_alloc(&dst->buf, src->size); if (ret < 0) goto fail;