From 464498c61595a231751bb7c53ccee645b330efdd Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Thu, 7 Oct 2021 12:28:53 +0800 Subject: [PATCH 1/2] Don't pass null strings to id3_ucs4_length. Issue #6 Signed-off-by: Michael Moon --- compat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat.c b/compat.c index 19f1d13..48d486a 100644 --- a/compat.c +++ b/compat.c @@ -439,6 +439,9 @@ int id3_compat_fixup(struct id3_tag *tag) encoding = id3_parse_uint(&data, 1); string = id3_parse_string(&data, end - data, encoding, 0); + if (!string) + continue; + if (id3_ucs4_length(string) < 4) { free(string); continue; From 8bfecd7e1ec8919cad3c7fe08ef83a2c9cbd1f92 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Thu, 7 Oct 2021 12:29:53 +0800 Subject: [PATCH 2/2] Add a sanity check to id3_ucs4_length. Issue #6 Signed-off-by: Michael Moon --- ucs4.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ucs4.c b/ucs4.c index f55f159..9d2e02b 100644 --- a/ucs4.c +++ b/ucs4.c @@ -37,6 +37,9 @@ id3_ucs4_t const id3_ucs4_empty[] = { 0 }; */ id3_length_t id3_ucs4_length(id3_ucs4_t const *ucs4) { + if (!ucs4) + return 0; + id3_ucs4_t const *ptr = ucs4; while (*ptr)