Mercurial > hg-stable
changeset 38974:05c1f5f49ebb
index: use PyMem_Free() to free nodeetree instance
As Yuya pointed out in the review of D4108, PyMem_Malloc() and
PyMem_Free() should be paired. IIUC, PyMem_Malloc() may use a
different allocator than malloc(), so using free() with a pointer from
PyMem_Malloc() may be very wrong.
Differential Revision: https://phab.mercurial-scm.org/D4152
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 06 Aug 2018 22:24:34 -0700 |
parents | 27a54096c92e |
children | f7d8fb2ed8a8 |
files | mercurial/cext/revlog.c |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cext/revlog.c Mon Aug 06 22:24:00 2018 -0700 +++ b/mercurial/cext/revlog.c Mon Aug 06 22:24:34 2018 -0700 @@ -323,7 +323,7 @@ } if (self->nt != NULL) { free(self->nt->nodes); - free(self->nt); + PyMem_Free(self->nt); } self->nt = NULL; Py_CLEAR(self->headrevs); @@ -1106,7 +1106,7 @@ self->nt->nodes = calloc(self->nt->capacity, sizeof(nodetreenode)); if (self->nt->nodes == NULL) { - free(self->nt); + PyMem_Free(self->nt); self->nt = NULL; PyErr_NoMemory(); return -1; @@ -1119,7 +1119,7 @@ self->nt->length = 1; if (nt_insert(self, nullid, -1) == -1) { free(self->nt->nodes); - free(self->nt); + PyMem_Free(self->nt); self->nt = NULL; return -1; }