File tree 1 file changed +8
-28
lines changed 1 file changed +8
-28
lines changed Original file line number Diff line number Diff line change @@ -975,44 +975,24 @@ const char *PyFT2Font_get_charmap__doc__ =
975
975
static PyObject *PyFT2Font_get_charmap (PyFT2Font *self, PyObject *args, PyObject *kwds)
976
976
{
977
977
PyObject *charmap;
978
-
979
- charmap = PyDict_New ();
980
- if (charmap == NULL ) {
978
+ if (!(charmap = PyDict_New ())) {
981
979
return NULL ;
982
980
}
983
-
984
981
FT_UInt index ;
985
982
FT_ULong code = FT_Get_First_Char (self->x ->get_face (), &index );
986
983
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) {
1006
991
Py_DECREF (charmap);
1007
992
return NULL ;
1008
993
}
1009
-
1010
- Py_DECREF (key);
1011
- Py_DECREF (val);
1012
-
1013
994
code = FT_Get_Next_Char (self->x ->get_face (), code, &index );
1014
995
}
1015
-
1016
996
return charmap;
1017
997
}
1018
998
You can’t perform that action at this time.
0 commit comments