summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Python/getopt.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/getopt.c b/Python/getopt.c
index 80a00ef..91aaa28 100644
--- a/Python/getopt.c
+++ b/Python/getopt.c
@@ -62,7 +62,10 @@ char optstring[];
opt_ptr = &argv[optind++][1];
}
- if ((ptr = strchr(optstring, option = *opt_ptr++)) == NULL) {
+ if ( (option = *opt_ptr++) == '\0')
+ return -1;
+
+ if ((ptr = strchr(optstring, option)) == NULL) {
if (opterr)
fprintf(stderr, "Unknown option: -%c\n", option);