diff mbox series

[FFmpeg-devel,06/18] avformat/apetag: Avoid stack packet when reading attached picture

Message ID 20210319055904.2264501-6-andreas.rheinhardt@gmail.com
State Accepted
Commit ab5803553b3932da3227647ae27f2e2795cc5752
Headers show
Series [FFmpeg-devel,01/18] libavformat/utils: Fix indentation
Related show

Checks

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

Commit Message

Andreas Rheinhardt March 19, 2021, 5:58 a.m. UTC
Read it directly into AVStream.attached_pic.

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

Comments

Andreas Rheinhardt March 21, 2021, 7:45 p.m. UTC | #1
Andreas Rheinhardt:
> Read it directly into AVStream.attached_pic.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/apetag.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/libavformat/apetag.c b/libavformat/apetag.c
> index 454c6c688b..23ee6b516d 100644
> --- a/libavformat/apetag.c
> +++ b/libavformat/apetag.c
> @@ -79,10 +79,9 @@ static int ape_tag_read_field(AVFormatContext *s)
>          av_dict_set(&st->metadata, key, filename, 0);
>  
>          if ((id = ff_guess_image2_codec(filename)) != AV_CODEC_ID_NONE) {
> -            AVPacket pkt;
>              int ret;
>  
> -            ret = av_get_packet(s->pb, &pkt, size);
> +            ret = av_get_packet(s->pb, &st->attached_pic, size);
>              if (ret < 0) {
>                  av_log(s, AV_LOG_ERROR, "Error reading cover art.\n");
>                  return ret;
> @@ -92,7 +91,6 @@ static int ape_tag_read_field(AVFormatContext *s)
>              st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>              st->codecpar->codec_id   = id;
>  
> -            st->attached_pic              = pkt;
>              st->attached_pic.stream_index = st->index;
>              st->attached_pic.flags       |= AV_PKT_FLAG_KEY;
>          } else {
> 
Will apply.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 454c6c688b..23ee6b516d 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -79,10 +79,9 @@  static int ape_tag_read_field(AVFormatContext *s)
         av_dict_set(&st->metadata, key, filename, 0);
 
         if ((id = ff_guess_image2_codec(filename)) != AV_CODEC_ID_NONE) {
-            AVPacket pkt;
             int ret;
 
-            ret = av_get_packet(s->pb, &pkt, size);
+            ret = av_get_packet(s->pb, &st->attached_pic, size);
             if (ret < 0) {
                 av_log(s, AV_LOG_ERROR, "Error reading cover art.\n");
                 return ret;
@@ -92,7 +91,6 @@  static int ape_tag_read_field(AVFormatContext *s)
             st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
             st->codecpar->codec_id   = id;
 
-            st->attached_pic              = pkt;
             st->attached_pic.stream_index = st->index;
             st->attached_pic.flags       |= AV_PKT_FLAG_KEY;
         } else {