aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-04-18 15:19:40 -0300
committerJames Almer <jamrial@gmail.com>2018-04-18 23:01:29 -0300
commit53803ef71c7958d56d378b1486bfe0b077bb8958 (patch)
tree339e1aa18fc9e8d9ce9dc103237fdcd4315e9c38 /libavdevice
parent1fd992af60453e1ff4d3fd3af71a6891e5bd549d (diff)
downloadffmpeg-53803ef71c7958d56d378b1486bfe0b077bb8958.tar.gz
avdevice/iec61883: return reference counted packets
Fixes part of ticket #7146, dealing with leaks of packet data since commit 87c88122703f2befcf96383d05bdf14373c22df9. Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit b8629654c6460a28c507f816a977914e3a6f2520)
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/iec61883.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 721dca38ee..aeca7616df 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int length,
goto exit;
}
- packet->buf = av_malloc(length);
+ packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
if (!packet->buf) {
av_free(packet);
ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int length,
packet->len = length;
memcpy(packet->buf, data, length);
+ memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
if (dv->queue_first) {
dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data *dv, AVPacket *pkt)
size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
packet->buf, packet->len, -1);
dv->queue_first = packet->next;
+ if (size < 0)
+ av_free(packet->buf);
av_free(packet);
dv->packets--;
- if (size > 0)
- return size;
+ if (size < 0)
+ return -1;
- return -1;
+ if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+ av_freep(&pkt->data);
+ av_packet_unref(pkt);
+ return -1;
+ }
+
+ return size;
}
static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)