File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,19 @@ wmain(int argc, wchar_t **argv)
1818int
1919main (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 ++ ) {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments