From bac4932cf5d8f5cb1af6eca5fcdac05239489e2c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 13 May 2023 22:00:04 +0200 Subject: -fix templating tests --- src/templating/test6/test-custom-write.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/templating/test6/test-custom-write.c') diff --git a/src/templating/test6/test-custom-write.c b/src/templating/test6/test-custom-write.c index cc50a47cb..4ba953a85 100644 --- a/src/templating/test6/test-custom-write.c +++ b/src/templating/test6/test-custom-write.c @@ -1,6 +1,5 @@ /* Author: José Bollo - Author: José Bollo https://gitlab.com/jobol/mustach @@ -36,7 +35,7 @@ static char *readfile(const char *filename) { int f; struct stat s; - char *result; + char *result, *ptr; size_t size, pos; ssize_t rc; @@ -80,7 +79,10 @@ static char *readfile(const char *filename) pos += (size_t)rc; if (pos > size) { size = pos + BLOCKSIZE; - result = realloc(result, size + 1); + ptr = realloc(result, size + 1); + if (!ptr) + free(result); + result = ptr; } } } while(rc > 0); @@ -132,7 +134,7 @@ int main(int ac, char **av) mode = None; else { t = readfile(*av); - s = umustach_json_c(t, o, uwrite, NULL); + s = mustach_json_c_write(t, 0, o, Mustach_With_AllExtensions, uwrite, NULL); if (s != 0) fprintf(stderr, "Template error %d\n", s); free(t); -- cgit v1.2.3