mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Fix some missing checks after PyTuple_New, PyList_New, PyDict_New
This commit is contained in:
parent
a5a0704942
commit
5c170fd4a9
7 changed files with 27 additions and 7 deletions
|
|
@ -935,24 +935,32 @@ build_namelists (PyObject *module)
|
|||
|
||||
labels = PyList_New(num_controls);
|
||||
names = PyList_New(num_controls);
|
||||
if (labels == NULL || names == NULL)
|
||||
goto error2;
|
||||
for (i = 0; i < num_controls; i++) {
|
||||
s = PyString_FromString(control_labels[i]);
|
||||
if (s == NULL)
|
||||
return -1;
|
||||
goto error2;
|
||||
PyList_SET_ITEM(labels, i, s);
|
||||
|
||||
s = PyString_FromString(control_names[i]);
|
||||
if (s == NULL)
|
||||
return -1;
|
||||
goto error2;
|
||||
PyList_SET_ITEM(names, i, s);
|
||||
}
|
||||
|
||||
if (PyModule_AddObject(module, "control_labels", labels) == -1)
|
||||
return -1;
|
||||
goto error2;
|
||||
if (PyModule_AddObject(module, "control_names", names) == -1)
|
||||
return -1;
|
||||
goto error1;
|
||||
|
||||
return 0;
|
||||
|
||||
error2:
|
||||
Py_XDECREF(labels);
|
||||
error1:
|
||||
Py_XDECREF(names);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue