Fix a regression that caused a segfault when using scrollback_pager_history_size

Fixes #3011
This commit is contained in:
Kovid Goyal 2020-10-06 13:28:48 +05:30
parent b04b0c670d
commit fb87fc32f0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 2 deletions

View File

@ -10,6 +10,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- hints kitten: Add an ``ip`` type for easy selection of IP addresses
(:pull:`3009`)
- Fix a regression that caused a segfault when using
:opt:`scrollback_pager_history_size` and it gets full (:iss:`3011`)
- Fix update available notifications repeating (:pull:`3006`)

View File

@ -78,8 +78,8 @@ free_pagerhist(HistoryBuf *self) {
static inline bool
pagerhist_extend(PagerHistoryBuf *ph, size_t minsz) {
if (ph->buffer_size >= ph->max_sz) return false;
size_t newsz = ph->buffer_size + MAX(1024u * 1024u, minsz);
uint8_t *newbuf = PyMem_Malloc(MIN(ph->buffer_size + minsz, ph->max_sz));
size_t newsz = MIN(ph->max_sz, ph->buffer_size + MAX(1024u * 1024u, minsz));
uint8_t *newbuf = PyMem_Malloc(newsz);
if (!newbuf) return false;
size_t copied = MIN(ph->length, ph->buffer_size - ph->start);
if (copied) memcpy(newbuf, ph->buffer + ph->start, copied);