diff --git a/dbms/src/Common/ThreadProfileEvents.cpp b/dbms/src/Common/ThreadProfileEvents.cpp index 981380831de..7a964797be8 100644 --- a/dbms/src/Common/ThreadProfileEvents.cpp +++ b/dbms/src/Common/ThreadProfileEvents.cpp @@ -105,8 +105,12 @@ namespace DB { return false; str[MAX_LENGTH - 1] = '\0'; - // todo: change to `strtol` - result = atoi(str); + long value = strtol(str, nullptr, 10); + // the only way to be incorrect is to not be a number + if (value == 0 && errno != 0) + return false; + + result = static_cast(value); return true; }