diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2008-09-03 18:58:51 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2008-09-03 18:58:51 +0000 |
commit | e7847e17e67cf957409e886abd4e664d88dcea76 (patch) | |
tree | 115daa1faa182ef006df1d066bf360b6d84b2ca9 /Python/frozenmain.c | |
parent | cce40c011a5d64fa277ec66015024b9f26250de4 (diff) | |
download | cpython-e7847e17e67cf957409e886abd4e664d88dcea76.tar.gz |
Issue #3696: Error parsing arguments on OpenBSD <= 4.4 and Cygwin.
Patch by Amaury Forgeot d'Arc, reviewed by me.
Diffstat (limited to 'Python/frozenmain.c')
-rw-r--r-- | Python/frozenmain.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/frozenmain.c b/Python/frozenmain.c index 88c34651dc..a5e73609b3 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -45,7 +45,12 @@ Py_FrozenMain(int argc, char **argv) oldloc = setlocale(LC_ALL, NULL); setlocale(LC_ALL, ""); for (i = 0; i < argc; i++) { +#ifdef HAVE_BROKEN_MBSTOWCS + size_t argsize = strlen(argv[i]); +#else size_t argsize = mbstowcs(NULL, argv[i], 0); +#endif + size_t count; if (argsize == (size_t)-1) { fprintf(stderr, "Could not convert argument %d to string", i); return 1; @@ -56,7 +61,11 @@ Py_FrozenMain(int argc, char **argv) fprintf(stderr, "out of memory"); return 1; } - mbstowcs(argv_copy[i], argv[i], argsize+1); + count = mbstowcs(argv_copy[i], argv[i], argsize+1); + if (count == (size_t)-1) { + fprintf(stderr, "Could not convert argument %d to string", i); + return 1; + } } setlocale(LC_ALL, oldloc); |