commit 0f1bba8a554b1f411a343110aa63395f51a5f99b
parent 316207e46c77af30aab77b260656abad8b34d506
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 25 Nov 2016 17:02:32 +0100
fix possible invalid free
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/saait.c b/saait.c
@@ -532,8 +532,15 @@ writepage(FILE *fp, const char *filename, struct config *c, char *s)
value = v->value;
/* TODO: optimize output directly (buffered) */
- if (op == '%')
+ if (op == '%') {
value = readfile(value);
+ fputs(value, fp);
+ free(value);
+ for (e = s; *e && *e != '}'; e++)
+ ;
+ s = e;
+ continue;
+ }
/* format date */
if (*s == '@') {
@@ -559,9 +566,6 @@ writepage(FILE *fp, const char *filename, struct config *c, char *s)
xmlencode(value, fp);
else
fputs(value, fp);
-
- if (op == '%')
- free(value);
}
}