changeset 17921:58c1b50299a6

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.
author Pádraig Brady <P@draigBrady.com>
date Wed, 18 Feb 2015 22:37:31 +0000
parents 7a288a43abf9
children 1092f168a05e
files lib/getopt.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -527,6 +527,8 @@
                 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 @@
                 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