From 38cc61bbdcf2ffd3b04b93e3e781e5d1689a5eef Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Thu, 22 Oct 2026 10:50:25 +0200 Subject: [PATCH] Sometimes test t/mp3.t fails with a segmentation fault. Reason is that the buffer is read for a NUL check before the length is checked. Always check the length before reading to avoid falling off behind buffer size. Signed-off-by: Paul Gevers --- src/ape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape.c b/src/ape.c index fe04650..97131e4 100644 --- a/src/ape.c +++ b/src/ape.c @@ -307,7 +307,7 @@ int _ape_parse_field(ApeTag* tag) { // Bug 9942, APE tags can contain multiple items with a null separator tmp_ptr = buffer_ptr(&tag->tag_data); - while (tmp_ptr[0] != '\0' && val_length <= size) { + while (val_length <= size && tmp_ptr[0] != '\0') { val_length += 1; tmp_ptr += 1; }