Message ID | 20210507171719.930-1-jamrial@gmail.com |
---|---|
State | Accepted |
Commit | 0a029906b205613c7744bcef4cdda184199dd1a9 |
Headers | show |
Series | [FFmpeg-devel] avcodec/avpacket: always initialize the new packet in avpriv_packet_list_put() | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
On 5/7/2021 2:17 PM, James Almer wrote: > 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> > --- > libavcodec/avpacket.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > 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 Will apply.
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
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> --- libavcodec/avpacket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)