diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-10-31 06:42:08 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-01-13 16:31:40 +0100 |
commit | 90cfc084e3e6d37ab88fc96a95f0401d8e8b4cd1 (patch) | |
tree | cb1ede811c8ece8ef67ef7045c4ef73582b01aa2 | |
parent | 49dc82eef776634ac2da41fca9f105df25129ad8 (diff) | |
download | ffmpeg-90cfc084e3e6d37ab88fc96a95f0401d8e8b4cd1.tar.gz |
avpacket: free side data in av_free_packet().
Freeing it in av_destruct_packet(), as is done currently, would mean
that we allow it to be allocated with other means. But that would make
av_packet_new_side_data() unsafe.
Side data is not expected to be large, so copying it if required
shouldn't be a problem.
-rw-r--r-- | libavcodec/avpacket.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index cb24948a48..c26fb8e35c 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -27,16 +27,9 @@ void av_destruct_packet(AVPacket *pkt) { - int i; - av_free(pkt->data); pkt->data = NULL; pkt->size = 0; - - for (i = 0; i < pkt->side_data_elems; i++) - av_free(pkt->side_data[i].data); - av_freep(&pkt->side_data); - pkt->side_data_elems = 0; } void av_init_packet(AVPacket *pkt) @@ -153,11 +146,16 @@ failed_alloc: void av_free_packet(AVPacket *pkt) { if (pkt) { + int i; + if (pkt->destruct) pkt->destruct(pkt); pkt->data = NULL; pkt->size = 0; - pkt->side_data = NULL; + + for (i = 0; i < pkt->side_data_elems; i++) + av_free(pkt->side_data[i].data); + av_freep(&pkt->side_data); pkt->side_data_elems = 0; } } |