mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-18 06:20:51 +00:00
Paranoid str to int check
This commit is contained in:
parent
ca7b5a3a05
commit
50c603a74c
@ -105,8 +105,12 @@ namespace DB {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
str[MAX_LENGTH - 1] = '\0';
|
str[MAX_LENGTH - 1] = '\0';
|
||||||
// todo: change to `strtol`
|
long value = strtol(str, nullptr, 10);
|
||||||
result = atoi(str);
|
// the only way to be incorrect is to not be a number
|
||||||
|
if (value == 0 && errno != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
result = static_cast<int>(value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user