]> granicus.if.org Git - curl/commitdiff
curl: make str2udouble not return values on error
authorDaniel Stenberg <daniel@haxx.se>
Fri, 15 Sep 2017 14:38:48 +0000 (16:38 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 18 Sep 2017 08:45:29 +0000 (10:45 +0200)
... previously it would store a return value even when it returned
error, which could make the value get used anyway!

Reported-by: Brian Carpenter
Closes #1893

src/tool_paramhlp.c

index 42631e9c3eea91002abfe7a07b39c4f1e36c83b3..7cddf51ce8914efc471509f5ec7c65300c82442e 100644 (file)
@@ -242,14 +242,16 @@ static ParameterError str2double(double *val, const char *str, long max)
  * data.
  */
 
-ParameterError str2udouble(double *val, const char *str, long max)
+ParameterError str2udouble(double *valp, const char *str, long max)
 {
-  ParameterError result = str2double(val, str, max);
+  double value;
+  ParameterError result = str2double(&value, str, max);
   if(result != PARAM_OK)
     return result;
-  if(*val < 0)
+  if(value < 0)
     return PARAM_NEGATIVE_NUMERIC;
 
+  *valp = value;
   return PARAM_OK;
 }