summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-27 01:04:56 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-07-27 01:04:56 +0200
commitbbbd4734657844b03c7e78de83e16983d7806094 (patch)
tree87fa3c616b493ec758cadeccd64f0b6d37ab011e /Modules
parentda7db911620efbe87a73ed0ea5f2b1e01327505e (diff)
downloadcpython-bbbd4734657844b03c7e78de83e16983d7806094.tar.gz
Issue #15893: frozenmain.c now handles PyMem_Malloc() failure
Diffstat (limited to 'Modules')
-rw-r--r--Modules/python.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/Modules/python.c b/Modules/python.c
index 8a548d3ac3..f781d9a525 100644
--- a/Modules/python.c
+++ b/Modules/python.c
@@ -18,11 +18,19 @@ wmain(int argc, wchar_t **argv)
int
main(int argc, char **argv)
{
- wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
+ wchar_t **argv_copy;
/* We need a second copy, as Python might modify the first one. */
- wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
+ wchar_t **argv_copy2;
int i, res;
char *oldloc;
+
+ argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
+ argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
+ if (!argv_copy || !argv_copy2) {
+ fprintf(stderr, "out of memory\n");
+ return 1;
+ }
+
/* 754 requires that FP exceptions run in "no stop" mode by default,
* and until C vendors implement C99's ways to control FP exceptions,
* Python requires non-stop mode. Alas, some platforms enable FP
@@ -34,10 +42,6 @@ main(int argc, char **argv)
m = fpgetmask();
fpsetmask(m & ~FP_X_OFL);
#endif
- if (!argv_copy || !argv_copy2) {
- fprintf(stderr, "out of memory\n");
- return 1;
- }
oldloc = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "");
for (i = 0; i < argc; i++) {