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:
parent
aff1d373b1
commit
edcbb3e1b9
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user