Free ranges correctly if style is not terminated, GitHub issue 5795 from

mail at luftaquila dot io.
This commit is contained in:
nicm authored and tmux update bot committed 2026-10-23 12:10:04 +00:00
1 parent d34d16b4bd
commit 8f79674b10
1 file changed
+9 -5
+9 -5
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: format-draw.c,v 1.37 2026/10/16 07:59:06 nicm Exp $ */
/* $OpenBSD: format-draw.c,v 1.38 2026/10/23 06:37:28 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -793,7 +793,7 @@ format_draw1(struct screen_write_ctx *octx, const struct format_style *fs,
RIGHT,
ABSOLUTE_CENTRE };
int focus_start = -1, focus_end = -1;
int list_state = -1, fill, even;
int list_state = -1, fill, even, error = 0;
enum style_align list_align = STYLE_ALIGN_DEFAULT;
struct grid_cell gc, cur_def, base_def;
struct style sy, saved_sy;
@@ -923,9 +923,8 @@ format_draw1(struct screen_write_ctx *octx, const struct format_style *fs,
if (end == NULL) {
log_debug("%s: no terminating ] at '%s'", __func__,
cp + 2);
TAILQ_FOREACH_SAFE(fr, &frs, entry, fr1)
format_free_range(&frs, fr);
goto out;
error = 1;
break;
}
tmp = xstrndup(cp + 2, end - (cp + 2));
style_copy(&saved_sy, &sy);
@@ -1079,6 +1078,11 @@ format_draw1(struct screen_write_ctx *octx, const struct format_style *fs,
screen_write_stop(&ctx[i]);
log_debug("%s: width %s is %u", __func__, names[i], width[i]);
}
if (error) {
TAILQ_FOREACH_SAFE(fr, &frs, entry, fr1)
format_free_range(&frs, fr);
goto out;
}
if (focus_start != -1 && focus_end != -1)
log_debug("%s: focus %d-%d", __func__, focus_start, focus_end);
TAILQ_FOREACH(fr, &frs, entry) {