From 458b87150b3fe989bb3d5d611f1d010a71839117 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 20 Mar 2019 07:28:31 +0000 Subject: [PATCH] Do not leak ranges on error. --- format-draw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/format-draw.c b/format-draw.c index 40ba27bf..ed50236f 100644 --- a/format-draw.c +++ b/format-draw.c @@ -577,7 +577,9 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, end = format_skip(cp + 2, "]"); if (end == NULL) { log_debug("no terminating ] at '%s'", cp + 2); - return; + TAILQ_FOREACH_SAFE(fr, &frs, entry, fr1) + format_free_range(&frs, fr); + goto out; } tmp = xstrndup(cp + 2, end - (cp + 2)); if (style_parse(&sy, base, tmp) != 0) { @@ -755,6 +757,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, format_free_range(&frs, fr); } +out: /* Free the screens. */ for (i = 0; i < TOTAL; i++) screen_free(&s[i]);