summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-02-18 22:37:31 +0000
committerPádraig Brady <P@draigBrady.com>2015-02-18 22:48:38 +0000
commit4ad02492559a3b95e0ab86d79dd0e0e611c0ac1d (patch)
tree73a4dff914ad528c5640b9ec14cdbd02c1fe25c4 /lib
parent6fa31e52cb3547f3c89b3a4c6547d1d92292ac15 (diff)
downloadgnulib-4ad02492559a3b95e0ab86d79dd0e0e611c0ac1d.tar.gz
getopt: give accurate ambiguity diagnostic on mem exhaustion
* lib/getopt.c (_getopt_internal_r): The previous commit broke out the loop too early, which could give a false indication of ambiguous options under memory exhaustion.
Diffstat (limited to 'lib')
-rw-r--r--lib/getopt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/getopt.c b/lib/getopt.c
index 6474ba74c9..212cbf7341 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -527,6 +527,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
pfound = p;
indfound = option_index;
}
+ else if (ambig)
+ ; /* Taking simpler path to handling ambiguities. */
else if (long_only
|| pfound->has_arg != p->has_arg
|| pfound->flag != p->flag
@@ -539,10 +541,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
struct option_list *newp = malloc (sizeof (*newp));
if (newp == NULL)
{
- ambig = 1; /* Use simpler fallback message. */
free_option_list (ambig_list);
ambig_list = NULL;
- break;
+ ambig = 1; /* Use simpler fallback message. */
}
else
#endif