Skip to content

Commit eb746db

Browse files
Alexey Izbyshevvstinner
authored andcommitted
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.
1 parent 3738fad commit eb746db

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/coreconfig.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ _Py_wstrlist_copy(int len, wchar_t **list)
6969
assert((len > 0 && list != NULL) || len == 0);
7070
size_t size = len * sizeof(list[0]);
7171
wchar_t **list_copy = PyMem_RawMalloc(size);
72+
if (list_copy == NULL) {
73+
return NULL;
74+
}
7275
for (int i=0; i < len; i++) {
7376
wchar_t* arg = _PyMem_RawWcsdup(list[i]);
7477
if (arg == NULL) {
75-
_Py_wstrlist_clear(i, list);
78+
_Py_wstrlist_clear(i, list_copy);
7679
return NULL;
7780
}
7881
list_copy[i] = arg;

0 commit comments

Comments
 (0)