aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-04-12 09:30:33 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-04-12 09:30:38 -0400
commit6250351905c60a8880e76d845a014e30b82af954 (patch)
treea94f673e91341c42ab9b496c8bd93c4b054686e3
parent4ac5832fff29d7d22919e3268780adefe5c2bc53 (diff)
downloadstasis-6250351905c60a8880e76d845a014e30b82af954.tar.gz
Fix invalid read
* Replaces the bare pointer while-loop with a for-loop and tests against the length of the string.
-rw-r--r--src/template.c5
1 files changed, 1 insertions, 4 deletions
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