aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag/ApeLoader.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/tag/ApeLoader.cxx')
-rw-r--r--src/tag/ApeLoader.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx
index c42d088a8..b1759a730 100644
--- a/src/tag/ApeLoader.cxx
+++ b/src/tag/ApeLoader.cxx
@@ -79,12 +79,12 @@ ape_scan_internal(FILE *fp, ApeTagCallback callback)
/* get the key */
const char *key = p;
- while (remaining > size && *p != '\0') {
- p++;
- remaining--;
- }
- p++;
- remaining--;
+ const char *key_end = (const char *)memchr(p, '\0', remaining);
+ if (key_end == nullptr)
+ break;
+
+ p = key_end + 1;
+ remaining -= p - key;
/* get the value */
if (remaining < size)