From 6250351905c60a8880e76d845a014e30b82af954 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 12 Apr 2024 09:30:33 -0400 Subject: Fix invalid read * Replaces the bare pointer while-loop with a for-loop and tests against the length of the string. --- src/template.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/template.c b/src/template.c index 14e40c2..58240de 100644 --- a/src/template.c +++ b/src/template.c @@ -150,9 +150,7 @@ char *tpl_render(char *str) { return NULL; } - size_t z = 0; - size_t off = 0; - while (pos[off] != 0) { + for (size_t off = 0, z = 0; off < strlen(str); off++) { char key[255] = {0}; char *value = NULL; @@ -229,7 +227,6 @@ char *tpl_render(char *str) { fprintf(stderr, "z=%zu, output_bytes=%zu\n", z, output_bytes); #endif output[z] = pos[off]; - off++; z++; } #ifdef DEBUG -- cgit