pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/36577e4e8cf967083dea762407ba9d9d28de5b8a

8faa60c69660fa.css" /> Issue #15893: frozenmain.c now handles PyMem_Malloc() failure · python/cpython@36577e4 · GitHub
Skip to content

Commit 36577e4

Browse files
committed
Issue #15893: frozenmain.c now handles PyMem_Malloc() failure
1 parent 70c94e7 commit 36577e4

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

Modules/python.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ wmain(int argc, wchar_t **argv)
1818
int
1919
main(int argc, char **argv)
2020
{
21-
wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
21+
wchar_t **argv_copy;
2222
/* We need a second copy, as Python might modify the first one. */
23-
wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
23+
wchar_t **argv_copy2;
2424
int i, res;
2525
char *oldloc;
26+
27+
argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
28+
argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
29+
if (!argv_copy || !argv_copy2) {
30+
fprintf(stderr, "out of memory\n");
31+
return 1;
32+
}
33+
2634
/* 754 requires that FP exceptions run in "no stop" mode by default,
2735
* and until C vendors implement C99's ways to control FP exceptions,
2836
* Python requires non-stop mode. Alas, some platforms enable FP
@@ -34,10 +42,6 @@ main(int argc, char **argv)
3442
m = fpgetmask();
3543
fpsetmask(m & ~FP_X_OFL);
3644
#endif
37-
if (!argv_copy || !argv_copy2) {
38-
fprintf(stderr, "out of memory\n");
39-
return 1;
40-
}
4145
oldloc = strdup(setlocale(LC_ALL, NULL));
4246
setlocale(LC_ALL, "");
4347
for (i = 0; i < argc; i++) {

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy