On Tue, 31 Dec 2024, Michael Niedermayer wrote:

Suggested-by: Marton Balint <c...@passwd.hu>
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
---
libavformat/vqf.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavformat/vqf.c b/libavformat/vqf.c
index 79deb33744b..5094724240e 100644
--- a/libavformat/vqf.c
+++ b/libavformat/vqf.c
@@ -51,23 +51,24 @@ static int vqf_probe(const AVProbeData *probe_packet)
    return AVPROBE_SCORE_EXTENSION;
}

-static void add_metadata(AVFormatContext *s, uint32_t tag,
+static int add_metadata(AVFormatContext *s, uint32_t tag,
                         unsigned int tag_len, unsigned int remaining)
{
    int len = FFMIN(tag_len, remaining);
    char *buf, key[5] = {0};

    if (len == UINT_MAX)
-        return;
+        return AVERROR(ENOMEM);

AVERROR_INVALIDDATA. Although this check seems redundant because you check lengths values earlier more strictly.


    buf = av_malloc(len+1);
    if (!buf)
-        return;
+        return AVERROR(ENOMEM);
    if (len != avio_read(s->pb, buf, len))
-        return;
+        return len < 0 ? len : AVERROR_INVALIDDATA;
    buf[len] = 0;
    AV_WL32(key, tag);
    av_dict_set(&s->metadata, key, buf, AV_DICT_DONT_STRDUP_VAL);

Why not simply return av_dict_set()?

+    return 0;
}

static const AVMetadataConv vqf_metadata_conv[] = {
@@ -164,10 +165,13 @@ static int vqf_read_header(AVFormatContext *s)
        case MKTAG('_','I','D','3'): // reserved for ID3 tags
            avio_skip(s->pb, FFMIN(len, header_size));
            break;
-        default:
-            add_metadata(s, chunk_tag, len, header_size);
+        default: {

New block seems unnecessary.

+            ret = add_metadata(s, chunk_tag, len, header_size);
+            if (ret < 0)
+                return ret;
            break;
        }
+        }

Thanks,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to