aboutsummaryrefslogtreecommitdiff
path: root/vt.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-03-20 15:31:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-03-21 19:40:10 +0000
commit0b9b726bdfb573337de09489ae0750070aec219a (patch)
treea370ab0c97d3294d72883a4456168e587a1a32db /vt.c
parentinput: don’t allow non-significant modifiers when matching untranslated symbols (diff)
vt: free OSC buffer after dispatch, if larger than 4K
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/vt.c b/vt.c
index d496fcfe..a98188be 100644
--- a/vt.c
+++ b/vt.c
@@ -577,11 +577,20 @@ action_osc_start(struct terminal *term, uint8_t c)
static void
action_osc_end(struct terminal *term, uint8_t c)
{
- if (!osc_ensure_size(term, term->vt.osc.idx + 1))
+ struct vt *vt = &term->vt;
+
+ if (!osc_ensure_size(term, vt->osc.idx + 1))
return;
- term->vt.osc.data[term->vt.osc.idx] = '\0';
- term->vt.osc.bel = c == '\a';
+
+ vt->osc.data[vt->osc.idx] = '\0';
+ vt->osc.bel = c == '\a';
osc_dispatch(term);
+
+ if (unlikely(vt->osc.idx >= 4096)) {
+ free(vt->osc.data);
+ vt->osc.data = NULL;
+ vt->osc.size = 0;
+ }
}
static void