diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-01 01:00:38 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-01 01:00:38 -0700 |
commit | 0a0b9e9122b5d5702968e224d0f3d830fb3c914d (patch) | |
tree | a1dd662afc32b7dd6791da65d32e9678be5d667f | |
parent | 428eb782eb401736d26adaa28c26bc1d6f78437e (diff) | |
download | pw-0a0b9e9122b5d5702968e224d0f3d830fb3c914d.tar.gz pw-0a0b9e9122b5d5702968e224d0f3d830fb3c914d.tar.bz2 pw-0a0b9e9122b5d5702968e224d0f3d830fb3c914d.zip |
Fix memory leak when resizing line buffer down.
Could happen when terminal window shrinks vertically.
-rw-r--r-- | pw.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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) |