Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 597696c

Browse files
committed
(Merge 3.3) Issue #15893: frozenmain.c now handles PyMem_Malloc() failure
2 parents b7f1b38 + 36577e4 commit 597696c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Python/frozenmain.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ Py_FrozenMain(int argc, char **argv)
2020
int inspect = 0;
2121
int unbuffered = 0;
2222
char *oldloc;
23-
wchar_t **argv_copy = PyMem_Malloc(sizeof(wchar_t*)*argc);
23+
wchar_t **argv_copy;
2424
/* We need a second copies, as Python might modify the first one. */
25-
wchar_t **argv_copy2 = PyMem_Malloc(sizeof(wchar_t*)*argc);
25+
wchar_t **argv_copy2;
26+
27+
argv_copy = PyMem_Malloc(sizeof(wchar_t*)*argc);
28+
argv_copy2 = PyMem_Malloc(sizeof(wchar_t*)*argc);
29+
if (!argv_copy || !argv_copy2) {
30+
fprintf(stderr, "out of memory\n");
31+
return 1;
32+
}
2633

2734
Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
2835

0 commit comments

Comments
 (0)