Skip to content

Commit 388bd4b

Browse files
Alexey Izbyshevvstinner
authored andcommitted
[3.7] bpo-34492: Modules/main.c: Fix copy_wstrlist() (GH-8910) (GH-8922)
* Add missing NULL check reported by Svace static analyzer. * Fix clear_wstrlist() call on a wrong list. (cherry picked from commit eb746db) Co-authored-by: Alexey Izbyshev <[email protected]>
1 parent 6dc8f05 commit 388bd4b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,10 +1236,13 @@ copy_wstrlist(int len, wchar_t **list)
12361236
assert((len > 0 && list != NULL) || len == 0);
12371237
size_t size = len * sizeof(list[0]);
12381238
wchar_t **list_copy = PyMem_RawMalloc(size);
1239+
if (list_copy == NULL) {
1240+
return NULL;
1241+
}
12391242
for (int i=0; i < len; i++) {
12401243
wchar_t* arg = _PyMem_RawWcsdup(list[i]);
12411244
if (arg == NULL) {
1242-
clear_wstrlist(i, list);
1245+
clear_wstrlist(i, list_copy);
12431246
return NULL;
12441247
}
12451248
list_copy[i] = arg;

0 commit comments

Comments
 (0)