diff --git a/src/mustach-dhcpd-pools.c b/src/mustach-dhcpd-pools.c index f88cc0e..c2ecc0f 100644 --- a/src/mustach-dhcpd-pools.c +++ b/src/mustach-dhcpd-pools.c @@ -61,11 +61,20 @@ struct expl { static int must_enter(void *closure, const char *name); static int must_leave(void *closure); +/* This can be called when template is invalid end put happens before enter. */ +int must_put_err(void *closure __attribute__ ((unused)), + const char *name __attribute__ ((unused)), + int escape __attribute__ ((unused)), + FILE *file __attribute__ ((unused))) +{ + return MUSTACH_ERROR_SYSTEM; +} + /* Set mustach function pointers. */ static struct mustach_itf itf = { .start = NULL, .enter = must_enter, - .put = NULL, + .put = must_put_err, .next = NULL, .leave = must_leave }; diff --git a/src/mustach.c b/src/mustach.c index e2da8b2..9868cff 100644 --- a/src/mustach.c +++ b/src/mustach.c @@ -38,7 +38,7 @@ static int getpartial(struct mustach_itf *itf, void *closure, const char *name, *result = NULL; file = open_memstream(result, &size); - if (itf->put == NULL || file == NULL) + if (file == NULL) rc = MUSTACH_ERROR_SYSTEM; else { rc = itf->put(closure, name, 0, file); @@ -192,8 +192,6 @@ static int process(const char *template, struct mustach_itf *itf, void *closure, default: /* replacement */ if (emit) { - if (itf->put == NULL) - return MUSTACH_ERROR_SYSTEM; rc = itf->put(closure, name, c != '&', file); if (rc < 0) return rc;