From 27701351e1385d61ed416a57faebde66735b1fdd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 1 Nov 2017 12:16:20 +0530 Subject: [PATCH] Fix double-free at exit if in alternate screen mode --- kitty/screen.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index b6d422be8..b5483e7b0 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -81,7 +81,8 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) { self->main_linebuf = alloc_linebuf(lines, columns); self->alt_linebuf = alloc_linebuf(lines, columns); self->linebuf = self->main_linebuf; self->historybuf = alloc_historybuf(MAX(scrollback, lines), columns); - self->main_grman = grman_alloc(); self->alt_grman = grman_alloc(); + self->main_grman = grman_alloc(); + self->alt_grman = grman_alloc(); self->grman = self->main_grman; self->main_tabstops = PyMem_Calloc(2 * self->columns, sizeof(bool)); if (self->cursor == NULL || self->main_linebuf == NULL || self->alt_linebuf == NULL || self->main_tabstops == NULL || self->historybuf == NULL || self->main_grman == NULL || self->alt_grman == NULL || self->color_profile == NULL) { @@ -213,7 +214,8 @@ static void dealloc(Screen* self) { pthread_mutex_destroy(&self->read_buf_lock); pthread_mutex_destroy(&self->write_buf_lock); - Py_CLEAR(self->grman); Py_CLEAR(self->alt_grman); + Py_CLEAR(self->main_grman); + Py_CLEAR(self->alt_grman); PyMem_RawFree(self->write_buf); Py_CLEAR(self->callbacks); Py_CLEAR(self->test_child);