summaryrefslogtreecommitdiff
path: root/libavcodec/avpacket.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-01-12 21:31:11 +0100
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-01-14 17:23:57 +0100
commitc4ba5198ea48f8f648d85a853ea46e29001c12c8 (patch)
treeb2cada03e1941b6241bcffdf24a6296c1450da7f /libavcodec/avpacket.c
parent45c39e566fe6d263e6ce0268b4629e5de3aa4d0c (diff)
Fix leaking of side data.
While we correctly "register" the side data when we split it, the application (in this case FFmpeg) might not update the AVPacket pool it uses to finally free the packet, thus causing a leak. This also makes the av_dup_packet unnecessary which could cause an even worse leak in this situation. Also change the code to not modify the user-provide AVPacket at all. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/avpacket.c')
-rw-r--r--libavcodec/avpacket.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index a4bd442176..5a51900ebf 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -20,6 +20,7 @@
*/
#include "avcodec.h"
+#include "internal.h"
#include "libavutil/avassert.h"
#include "bytestream.h"
@@ -30,19 +31,23 @@ void av_destruct_packet_nofree(AVPacket *pkt)
pkt->side_data_elems = 0;
}
-void av_destruct_packet(AVPacket *pkt)
+void ff_packet_free_side_data(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_destruct_packet(AVPacket *pkt)
+{
+ av_free(pkt->data);
+ pkt->data = NULL; pkt->size = 0;
+
+ ff_packet_free_side_data(pkt);
+}
+
void av_init_packet(AVPacket *pkt)
{
pkt->pts = AV_NOPTS_VALUE;
@@ -239,8 +244,6 @@ int av_packet_split_side_data(AVPacket *pkt){
unsigned int size;
uint8_t *p;
- av_dup_packet(pkt);
-
p = pkt->data + pkt->size - 8 - 5;
for (i=1; ; i++){
size = AV_RB32(p);