diff mbox series

[FFmpeg-devel,3/9] avfilter/lavfutils: Avoid initializing packet

Message ID 20200910214901.25401-3-andreas.rheinhardt@gmail.com
State Accepted
Commit 98171d14c5914933f19e244370f18321261e8b9f
Headers show
Series [FFmpeg-devel,1/9] avfilter/lavfutils: Don't use uninitialized pointers for freeing | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 10, 2020, 9:48 p.m. UTC
av_read_frame() can handle uninitialized packets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavfilter/lavfutils.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Nicolas George Sept. 11, 2020, 9:16 a.m. UTC | #1
Andreas Rheinhardt (12020-09-10):
> av_read_frame() can handle uninitialized packets.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavfilter/lavfutils.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

LGTM.

Regards,
diff mbox series

Patch

diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c
index d7de89f4b3..57af5ebfdc 100644
--- a/libavfilter/lavfutils.c
+++ b/libavfilter/lavfutils.c
@@ -35,8 +35,6 @@  int ff_load_image(uint8_t *data[4], int linesize[4],
     AVPacket pkt;
     AVDictionary *opt=NULL;
 
-    av_init_packet(&pkt);
-
     iformat = av_find_input_format("image2pipe");
     if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
         av_log(log_ctx, AV_LOG_ERROR,
@@ -89,6 +87,7 @@  int ff_load_image(uint8_t *data[4], int linesize[4],
     }
 
     ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
+    av_packet_unref(&pkt);
     if (ret < 0 || !frame_decoded) {
         av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
         if (ret >= 0)
@@ -107,7 +106,6 @@  int ff_load_image(uint8_t *data[4], int linesize[4],
     av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h);
 
 end:
-    av_packet_unref(&pkt);
     avcodec_free_context(&codec_ctx);
     avformat_close_input(&format_ctx);
     av_frame_free(&frame);