1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avformat/tests/fifo_muxer: Fix memleak on error, fix API violation

The test program for the FIFO muxer allocates a buffer without padding
and wraps it into a packet via av_packet_from_data(). This is an API
violation. Furthermore, said buffer leaks in case av_packet_from_data()
fails. Fix both of these issues by using av_new_packet() instead.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2021-03-19 01:31:31 +01:00
parent aff1d373b1
commit edcbb3e1b9

View File

@ -41,18 +41,15 @@ typedef struct FailingMuxerPacketData {
static int prepare_packet(AVPacket *pkt, const FailingMuxerPacketData *pkt_data, int64_t pts)
{
int ret;
FailingMuxerPacketData *data = av_malloc(sizeof(*data));
if (!data) {
return AVERROR(ENOMEM);
}
memcpy(data, pkt_data, sizeof(FailingMuxerPacketData));
ret = av_packet_from_data(pkt, (uint8_t*) data, sizeof(*data));
int ret = av_new_packet(pkt, sizeof(*pkt_data));
if (ret < 0)
return ret;
memcpy(pkt->data, pkt_data, sizeof(*pkt_data));
pkt->pts = pkt->dts = pts;
pkt->duration = 1;
return ret;
return 0;
}
static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc, AVPacket **pkt)