From b96d1f30be6fda4b3d93aef19e66273260503cac Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 28 Aug 2021 21:15:35 +0200 Subject: [PATCH] mp4: Check for missing metadata also for regular opens. Since we allow to update the metadata of a file handle returned by mp4_open(), we should check for both types of opens that the file actually contains the udta, meta and ilst atoms. --- mp4.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mp4.c b/mp4.c index 2121155c..7145a47a 100644 --- a/mp4.c +++ b/mp4.c @@ -609,6 +609,9 @@ static int open_file(const struct mp4_callback *cb, bool meta_only, struct mp4 * ret = -E_MP4_BAD_SAMPLERATE; if (f->track.sample_rate == 0) goto fail; + ret = -E_MP4_MISSING_ATOM; + if (f->udta_size == 0 || f->meta_size == 0 || f->ilst_size == 0) + goto fail; *result = f; return 1; fail: @@ -732,11 +735,6 @@ int mp4_open_meta(const struct mp4_callback *cb, struct mp4 **result) if (ret < 0) return ret; - if (f->udta_size == 0 || f->meta_size == 0 || f->ilst_size == 0) { - mp4_close(f); - *result = NULL; - return -E_MP4_MISSING_ATOM; - } *result = f; return 1; } -- 2.39.5