Fix another use after free caused by a re-assigned pointer
This commit is contained in:
parent
945cbca387
commit
3ee7e5f800
@ -397,7 +397,7 @@ pagerhist_write(HistoryBuf *self, PyObject *what) {
|
|||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
pagerhist_as_bytes(HistoryBuf *self, PyObject *args UNUSED) {
|
pagerhist_as_bytes(HistoryBuf *self, PyObject *args UNUSED) {
|
||||||
PagerHistoryBuf *ph = self->pagerhist;
|
#define ph self->pagerhist
|
||||||
if (!ph || !ringbuf_bytes_used(ph->ringbuf)) return PyBytes_FromStringAndSize("", 0);
|
if (!ph || !ringbuf_bytes_used(ph->ringbuf)) return PyBytes_FromStringAndSize("", 0);
|
||||||
pagerhist_ensure_start_is_valid_utf8(ph);
|
pagerhist_ensure_start_is_valid_utf8(ph);
|
||||||
if (ph->rewrap_needed) pagerhist_rewrap_to(self, self->xnum);
|
if (ph->rewrap_needed) pagerhist_rewrap_to(self, self->xnum);
|
||||||
@ -411,6 +411,7 @@ pagerhist_as_bytes(HistoryBuf *self, PyObject *args UNUSED) {
|
|||||||
ringbuf_memcpy_from(buf, ph->ringbuf, sz);
|
ringbuf_memcpy_from(buf, ph->ringbuf, sz);
|
||||||
if (!l.continued) buf[sz-1] = '\n';
|
if (!l.continued) buf[sz-1] = '\n';
|
||||||
return ans;
|
return ans;
|
||||||
|
#undef ph
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user