Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75caa48

Browse files
aitikguptatacaswell
authored andcommitted
Do not decref FT2Font pointers
1 parent 09755b4 commit 75caa48

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/ft2font_wrapper.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ static PyObject *PyFT2Font_fill_glyphs(PyFT2Font *self, PyObject *args, PyObject
664664
|| !(val = reinterpret_cast<PyObject *>(itr.second->get_pyfont()))
665665
|| (PyDict_SetItem(char_to_font, key, val) == -1));
666666
Py_XDECREF(key);
667-
Py_XDECREF(val);
667+
// do not decref value here, it's an FT2Font pointer
668+
668669
if (error) {
669670
Py_DECREF(char_to_font);
670671
return NULL;
@@ -702,7 +703,8 @@ static PyObject *PyFT2Font_get_char_to_font(PyFT2Font *self, PyObject *args, PyO
702703
|| !(val = reinterpret_cast<PyObject *>(itr.second->get_pyfont()))
703704
|| (PyDict_SetItem(char_to_font, key, val) == -1));
704705
Py_XDECREF(key);
705-
Py_XDECREF(val);
706+
// do not decref value here, it's an FT2Font pointer
707+
706708
if (error) {
707709
Py_DECREF(char_to_font);
708710
return NULL;
@@ -729,10 +731,9 @@ static PyObject *PyFT2Font_get_glyph_to_font(PyFT2Font *self, PyObject *args, Py
729731
bool error = (!(key = PyLong_FromLong(itr.first))
730732
|| !(val = reinterpret_cast<PyObject *>(itr.second->get_pyfont()))
731733
|| (PyDict_SetItem(glyph_to_font, key, val) == -1));
732-
// Py_XDECREF(key);
733-
// Py_XDECREF(val);
734-
Py_INCREF(val);
735-
Py_INCREF(key);
734+
Py_XDECREF(key);
735+
// do not decref value here, it's an FT2Font pointer
736+
736737
if (error) {
737738
Py_DECREF(glyph_to_font);
738739
return NULL;

0 commit comments

Comments
 (0)