Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ced284

Browse filesBrowse files
committed
Fix memory leaks found by memleak_hawaii3.py
1 parent de19d5c commit 3ced284
Copy full SHA for 3ced284

File tree

Expand file treeCollapse file tree

3 files changed

+12
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-4
lines changed

‎src/_path.h

Copy file name to clipboardExpand all lines: src/_path.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,6 @@ int convert_to_string(PathIterator &path,
11361136

11371137
*buffersize = path.total_vertices() * (precision + 5) * 4;
11381138
if (*buffersize == 0) {
1139-
*buffer = NULL;
11401139
return 0;
11411140
}
11421141

‎src/_path_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_path_wrapper.cpp
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,9 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
638638
PyObject *codesobj;
639639
char *codes[5];
640640
int postfix;
641-
char *buffer;
641+
char *buffer = NULL;
642642
size_t buffersize;
643+
PyObject *result;
643644
int status;
644645

645646
if (!PyArg_ParseTuple(args,
@@ -702,10 +703,14 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
702703
}
703704

704705
if (buffersize == 0) {
705-
return PyBytes_FromString("");
706+
result = PyBytes_FromString("");
706707
} else {
707-
return PyBytes_FromStringAndSize(buffer, buffersize);
708+
result = PyBytes_FromStringAndSize(buffer, buffersize);
708709
}
710+
711+
free(buffer);
712+
713+
return result;
709714
}
710715

711716
extern "C" {

‎src/ft2font_wrapper.cpp

Copy file name to clipboardExpand all lines: src/ft2font_wrapper.cpp
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,8 @@ static PyObject *PyFT2Font_get_name_index(PyFT2Font *self, PyObject *args, PyObj
10321032

10331033
CALL_CPP("get_name_index", name_index = self->x->get_name_index(glyphname));
10341034

1035+
PyMem_Free(glyphname);
1036+
10351037
return PyLong_FromLong(name_index);
10361038
}
10371039

@@ -1085,6 +1087,8 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
10851087
}
10861088
}
10871089

1090+
PyMem_Free(tagname);
1091+
10881092
void *table = FT_Get_Sfnt_Table(self->x->get_face(), (FT_Sfnt_Tag)tag);
10891093
if (!table) {
10901094
Py_RETURN_NONE;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.