tool_paramhlp: improve str2num(): avoid unnecessary call to strlen()

Closes #11742
This commit is contained in:
Gerome Fournier 2023-08-27 13:25:47 +02:00 committed by Daniel Stenberg
parent 864090ca39
commit 458c70db6a
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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 */
}