summaryrefslogtreecommitdiff
path: root/libavcodec/avpacket.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-05-06 23:55:32 -0300
committerJames Almer <jamrial@gmail.com>2021-05-08 18:31:56 -0300
commit0a029906b205613c7744bcef4cdda184199dd1a9 (patch)
treee72bbc3b70ace15a3a613ce20b9c749356145295 /libavcodec/avpacket.c
parentffd1316e441a8310cf1746d86fed165e17e10018 (diff)
avcodec/avpacket: always initialize the new packet in avpriv_packet_list_put()
If a copy callback is provided by the caller, the packet passed to it was zeroed instead of initialized with default values. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/avpacket.c')
-rw-r--r--libavcodec/avpacket.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index e32c467586..1f20cd1e6b 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -519,13 +519,14 @@ int avpriv_packet_list_put(PacketList **packet_buffer,
int (*copy)(AVPacket *dst, const AVPacket *src),
int flags)
{
- PacketList *pktl = av_mallocz(sizeof(PacketList));
+ PacketList *pktl = av_malloc(sizeof(PacketList));
int ret;
if (!pktl)
return AVERROR(ENOMEM);
if (copy) {
+ get_packet_defaults(&pktl->pkt);
ret = copy(&pktl->pkt, pkt);
if (ret < 0) {
av_free(pktl);
@@ -540,6 +541,8 @@ int avpriv_packet_list_put(PacketList **packet_buffer,
av_packet_move_ref(&pktl->pkt, pkt);
}
+ pktl->next = NULL;
+
if (*packet_buffer)
(*plast_pktl)->next = pktl;
else