]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_paramhlp: improve str2num(): avoid unnecessary call to strlen()
authorGerome Fournier <jef@foutaise.org>
Sun, 27 Aug 2023 11:25:47 +0000 (13:25 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 27 Aug 2023 15:55:05 +0000 (17:55 +0200)
Closes #11742

src/tool_paramhlp.c

index d2248442b1e2665b4b470e3df27cbb5a709bf817..d70e80db4bbec118f3338822c0ebfb3c35dfe7ab 100644 (file)
@@ -138,7 +138,7 @@ static ParameterError getnum(long *val, const char *str, int base)
     num = strtol(str, &endptr, base);
     if(errno == ERANGE)
       return PARAM_NUMBER_TOO_LARGE;
-    if((endptr != str) && (endptr == str + strlen(str))) {
+    if((endptr != str) && (*endptr == '\0')) {
       *val = num;
       return PARAM_OK;  /* Ok */
     }