[FFmpeg-devel] [PATCH] avformat/vqf: Propagate errors from add_metadata()
Alexander Strasser
eclipse7 at gmx.net
Tue Dec 31 17:42:15 EET 2024
Hi Michael!
On 2024-12-31 04:36 +0100, Michael Niedermayer wrote:
> Suggested-by: Marton Balint <cus at passwd.hu>
> Signed-off-by: Michael Niedermayer <michael at 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);
>
> 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;
This looks wrong if I understood this function correctly.
The variable *len* is only set at the beginning of the function.
If I understand the intent correctly we should either always return
AVERROR_INVALIDDATA or we should store the return value of avio_read
and return that if it's negative.
[...]
Alexander
More information about the ffmpeg-devel
mailing list