summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmListCommand.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index edfaeec..42f94b6 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -4,9 +4,7 @@
#include <algorithm>
#include <cassert>
-#include <cstddef>
#include <cstdio>
-#include <cstdlib> // required for atoi
#include <functional>
#include <iterator>
#include <set>
@@ -38,8 +36,14 @@ namespace {
bool GetIndexArg(char const* arg, int* idx)
{
- *idx = atoi(arg);
- // Ignore errors.
+ long value;
+ if (!cmStrToLong(arg, &value)) {
+ // An error was detected.
+ }
+
+ // Truncation is happening here, but it had always been happening here.
+ *idx = static_cast<int>(value);
+
return true;
}