Allow hex string lists
stoul will try and succeed to convert a hex list i.e.
"0x08 0x20" into the first numer, 8 in this example.
Make the quailification harder to meet to try to convert
it.
Change-Id: Ibbd7cf4442ef4d16be79a9040612b8b965aaffa6
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index 9198ee5..d993860 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -1115,15 +1115,25 @@
}
}
}
+
+ // convert hex numbers to ints
else if (boost::starts_with(value, "0x"))
{
try
{
- keyPair.value() = static_cast<uint64_t>(std::stoul(value, 0, 0));
+ size_t pos = 0;
+ int64_t temp = std::stoul(value, &pos, 0);
+ if (pos == value.size())
+ {
+ keyPair.value() = static_cast<uint64_t>(temp);
+ }
}
catch (std::invalid_argument)
{
}
+ catch (std::out_of_range)
+ {
+ }
}
}