Fix memory leaks found by memleak_hawaii3.py by mdboom · Pull Request #5359 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/_path.h
11 changes: 8 additions & 3 deletions src/_path_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,9 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
PyObject *codesobj;
char *codes[5];
int postfix;
char *buffer;
char *buffer = NULL;
size_t buffersize;
PyObject *result;
int status;

if (!PyArg_ParseTuple(args,
Expand Down Expand Up @@ -702,10 +703,14 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
}

if (buffersize == 0) {
return PyBytes_FromString("");
result = PyBytes_FromString("");
} else {
return PyBytes_FromStringAndSize(buffer, buffersize);
result = PyBytes_FromStringAndSize(buffer, buffersize);
}

free(buffer);

return result;
}

extern "C" {
Expand Down
4 changes: 4 additions & 0 deletions src/ft2font_wrapper.cpp