mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
bpo-34492: Python/coreconfig.c: Fix _Py_wstrlist_copy() (GH-8910)
bpo-34492: Python/coreconfig.c: Add missing NULL check to _Py_wstrlist_copy(). Fix _Py_wstrlist_clear() call on a wrong list. Reported by Svace static analyzer.
This commit is contained in:
parent
3738fadc67
commit
eb746dbae8
1 changed files with 4 additions and 1 deletions
|
@ -69,10 +69,13 @@ _Py_wstrlist_copy(int len, wchar_t **list)
|
||||||
assert((len > 0 && list != NULL) || len == 0);
|
assert((len > 0 && list != NULL) || len == 0);
|
||||||
size_t size = len * sizeof(list[0]);
|
size_t size = len * sizeof(list[0]);
|
||||||
wchar_t **list_copy = PyMem_RawMalloc(size);
|
wchar_t **list_copy = PyMem_RawMalloc(size);
|
||||||
|
if (list_copy == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
for (int i=0; i < len; i++) {
|
for (int i=0; i < len; i++) {
|
||||||
wchar_t* arg = _PyMem_RawWcsdup(list[i]);
|
wchar_t* arg = _PyMem_RawWcsdup(list[i]);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
_Py_wstrlist_clear(i, list);
|
_Py_wstrlist_clear(i, list_copy);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
list_copy[i] = arg;
|
list_copy[i] = arg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue