aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-03-19 01:31:31 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-03-19 02:25:02 +0100
commitedcbb3e1b91b53b6fcd641a7f40bd707c090e0a7 (patch)
tree63805b5c65bac739abf559da0b86715cae313c23
parentaff1d373b1d66064d4c07a6a83c86a0044eaad52 (diff)
downloadffmpeg-edcbb3e1b91b53b6fcd641a7f40bd707c090e0a7.tar.gz
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>
-rw-r--r--libavformat/tests/fifo_muxer.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
index e8970259c4..227c3d0210 100644
--- a/libavformat/tests/fifo_muxer.c
+++ b/libavformat/tests/fifo_muxer.c
@@ -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)