From 0a0b9e9122b5d5702968e224d0f3d830fb3c914d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 1 May 2022 01:00:38 -0700 Subject: Fix memory leak when resizing line buffer down. Could happen when terminal window shrinks vertically. --- pw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pw.c b/pw.c index 25f6354..baa62c5 100644 --- a/pw.c +++ b/pw.c @@ -560,6 +560,9 @@ static void sigwinch(int sig) static char **resizebuf(char **buf, size_t nlfrom, size_t nlto) { + if (nlfrom > nlto) + for (size_t i = nlto; i < nlfrom; i++) + dsdrop(buf[i]); if ((buf = realloc(buf, sizeof *buf * nlto)) == 0) panic("out of memory"); if (nlfrom < nlto) -- cgit v1.2.3