mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Don't use PyList_GetItemRef immediately after PyList_New
This commit is contained in:
parent
87596bd747
commit
40e7f511b3
|
@ -1205,6 +1205,16 @@ font_getvarnames(FontObject *self) {
|
|||
|
||||
num_namedstyles = master->num_namedstyles;
|
||||
list_names = PyList_New(num_namedstyles);
|
||||
|
||||
int *list_names_filled = PyMem_Malloc(num_namedstyles * sizeof(int));
|
||||
if (list_names_filled == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_namedstyles; i++) {
|
||||
list_names_filled[i] = 0;
|
||||
}
|
||||
|
||||
if (list_names == NULL) {
|
||||
FT_Done_MM_Var(library, master);
|
||||
return NULL;
|
||||
|
@ -1220,13 +1230,14 @@ font_getvarnames(FontObject *self) {
|
|||
}
|
||||
|
||||
for (j = 0; j < num_namedstyles; j++) {
|
||||
if (PyList_GetItemRef(list_names, j) != NULL) {
|
||||
if (list_names_filled[j]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (master->namedstyle[j].strid == name.name_id) {
|
||||
list_name = Py_BuildValue("y#", name.string, name.string_len);
|
||||
PyList_SetItem(list_names, j, list_name);
|
||||
list_names_filled[j] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user