adamdebreceni commented on a change in pull request #797:
URL: https://github.com/apache/nifi-minifi-cpp/pull/797#discussion_r440831812
##########
File path: libminifi/include/core/state/Value.h
##########
@@ -86,35 +87,57 @@ class Value {
}
virtual bool getValue(uint32_t &ref) {
- const auto negative = string_value.find_first_of('-') != std::string::npos;
- if (negative) {
- return false;
- }
- ref = std::stoul(string_value);
+ try {
+ uint32_t value;
+ utils::ValueParser(string_value).parseUInt32(value).parseEnd();
+ ref = value;
+ } catch(const utils::ParseException&) {
+ return false;
+ }
Review comment:
they are not ment to be more general, they are ment to be correct, all
these conversion methods are incorrect as they all happily convert `"1banana"`
to `1`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]