diff options
Diffstat (limited to 'Modules/python.c')
-rw-r--r-- | Modules/python.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/Modules/python.c b/Modules/python.c index f781d9a525..9811c01d49 100644 --- a/Modules/python.c +++ b/Modules/python.c @@ -23,9 +23,12 @@ main(int argc, char **argv) wchar_t **argv_copy2; int i, res; char *oldloc; +#ifdef __FreeBSD__ + fp_except_t m; +#endif - argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1)); - argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1)); + argv_copy = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1)); + argv_copy2 = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1)); if (!argv_copy || !argv_copy2) { fprintf(stderr, "out of memory\n"); return 1; @@ -37,17 +40,21 @@ main(int argc, char **argv) * exceptions by default. Here we disable them. */ #ifdef __FreeBSD__ - fp_except_t m; - m = fpgetmask(); fpsetmask(m & ~FP_X_OFL); #endif - oldloc = strdup(setlocale(LC_ALL, NULL)); + + oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL)); + if (!oldloc) { + fprintf(stderr, "out of memory\n"); + return 1; + } + setlocale(LC_ALL, ""); for (i = 0; i < argc; i++) { argv_copy[i] = _Py_char2wchar(argv[i], NULL); if (!argv_copy[i]) { - free(oldloc); + PyMem_RawFree(oldloc); fprintf(stderr, "Fatal Python error: " "unable to decode the command line argument #%i\n", i + 1); @@ -58,13 +65,13 @@ main(int argc, char **argv) argv_copy2[argc] = argv_copy[argc] = NULL; setlocale(LC_ALL, oldloc); - free(oldloc); + PyMem_RawFree(oldloc); res = Py_Main(argc, argv_copy); for (i = 0; i < argc; i++) { - PyMem_Free(argv_copy2[i]); + PyMem_RawFree(argv_copy2[i]); } - PyMem_Free(argv_copy); - PyMem_Free(argv_copy2); + PyMem_RawFree(argv_copy); + PyMem_RawFree(argv_copy2); return res; } #endif |