mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-15 13:21:09 +08:00
avcodec/avcodec, avpacket: Return blank packet on av_packet_ref() failure
Up until now, it was completely unspecified what the content of the destination packet dst was on error. Depending upon where the error happened calling av_packet_unref() on dst might be dangerous. This commit changes this by making sure that dst is blank on error, so unreferencing it again is safe (and still pointless). This behaviour is documented. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
@@ -610,12 +610,13 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dst->buf = NULL;
|
||||
|
||||
ret = av_packet_copy_props(dst, src);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto fail;
|
||||
|
||||
if (!src->buf) {
|
||||
dst->buf = NULL;
|
||||
ret = packet_alloc(&dst->buf, src->size);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
@@ -637,7 +638,7 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
av_packet_free_side_data(dst);
|
||||
av_packet_unref(dst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user