File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -975,44 +975,24 @@ const char *PyFT2Font_get_charmap__doc__ =
975975static PyObject *PyFT2Font_get_charmap (PyFT2Font *self, PyObject *args, PyObject *kwds)
976976{
977977 PyObject *charmap;
978-
979- charmap = PyDict_New ();
980- if (charmap == NULL ) {
978+ if (!(charmap = PyDict_New ())) {
981979 return NULL ;
982980 }
983-
984981 FT_UInt index;
985982 FT_ULong code = FT_Get_First_Char (self->x ->get_face (), &index);
986983 while (index != 0 ) {
987- PyObject *key;
988- PyObject *val;
989-
990- key = PyLong_FromLong (code);
991- if (key == NULL ) {
992- Py_DECREF (charmap);
993- return NULL ;
994- }
995-
996- val = PyLong_FromLong (index);
997- if (val == NULL ) {
998- Py_DECREF (key);
999- Py_DECREF (charmap);
1000- return NULL ;
1001- }
1002-
1003- if (PyDict_SetItem (charmap, key, val)) {
1004- Py_DECREF (key);
1005- Py_DECREF (val);
984+ PyObject *key = NULL , *val = NULL ;
985+ bool error = (!(key = PyLong_FromLong (code))
986+ || !(val = PyLong_FromLong (index))
987+ || (PyDict_SetItem (charmap, key, val) == -1 ));
988+ Py_XDECREF (key);
989+ Py_XDECREF (val);
990+ if (error) {
1006991 Py_DECREF (charmap);
1007992 return NULL ;
1008993 }
1009-
1010- Py_DECREF (key);
1011- Py_DECREF (val);
1012-
1013994 code = FT_Get_Next_Char (self->x ->get_face (), code, &index);
1014995 }
1015-
1016996 return charmap;
1017997}
1018998
You can’t perform that action at this time.
0 commit comments