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>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user