]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
getparameter: avoid returning uninitialized 'usedarg'
authorDaniel Stenberg <daniel@haxx.se>
Fri, 4 Aug 2017 09:49:27 +0000 (11:49 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 5 Aug 2017 09:52:27 +0000 (11:52 +0200)
Fixes #1728

src/tool_getparam.c
src/tool_parsecfg.c

index cc2d816f150c2cafa2fd13da536041655b876b3d..089d2857435197aa4fb7d3cf34c5dbf01c6b6c58 100644 (file)
@@ -443,6 +443,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
   bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled
                          by using --OPTION or --no-OPTION */
 
+  *usedarg = FALSE; /* default is that we don't use the arg */
 
   if(('-' != flag[0]) ||
      (('-' == flag[0]) && ('-' == flag[1]))) {
@@ -496,7 +497,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
       letter = parse[0];
       subletter = parse[1];
     }
-    *usedarg = FALSE; /* default is that we don't use the arg */
 
     if(hit < 0) {
       for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
index 8432e5794395c6cea6f08c1fdf767922a362df3d..93814f4543c040f41bc224518cdf4a55a09437fd 100644 (file)
@@ -49,7 +49,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
   int res;
   FILE *file;
   char filebuffer[512];
-  bool usedarg;
+  bool usedarg = FALSE;
   char *home;
   int rc = 0;
   struct OperationConfig *operation = global->first;
@@ -220,7 +220,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
 #endif
       res = getparameter(option, param, &usedarg, global, operation);
 
-      if(param && *param && !usedarg)
+      if(!res && param && *param && !usedarg)
         /* we passed in a parameter that wasn't used! */
         res = PARAM_GOT_EXTRA_PARAMETER;