summaryrefslogtreecommitdiff
path: root/Modules/python.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/python.c')
-rw-r--r--Modules/python.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/python.c b/Modules/python.c
index 2be69f1f54..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));
- /* We need a second copies, as Python might modify the first one. */
- wchar_t **argv_copy2 = (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;
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,15 +42,12 @@ 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++) {
argv_copy[i] = _Py_char2wchar(argv[i], NULL);
if (!argv_copy[i]) {
+ free(oldloc);
fprintf(stderr, "Fatal Python error: "
"unable to decode the command line argument #%i\n",
i + 1);