Skip to content

Commit 98eb6e4

Browse files
committed
Change stoul to ParseUInt32 in poll.cpp
1 parent f597d73 commit 98eb6e4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/gridcoin/voting/poll.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,13 @@ namespace {
2525
//!
2626
PollWeightType ParseWeightType(const std::string& value)
2727
{
28-
try {
29-
const uint32_t parsed = std::stoul(value);
28+
uint32_t parsed = 0;
3029

31-
if (parsed > Poll::WeightType::MAX) {
30+
if (!::ParseUInt32(value, &parsed) || parsed > Poll::WeightType::MAX) {
3231
return PollWeightType::UNKNOWN;
3332
}
3433

3534
return static_cast<PollWeightType>(parsed);
36-
} catch (...) {
37-
return PollWeightType::UNKNOWN;
38-
}
3935
}
4036

4137
//!
@@ -48,11 +44,13 @@ PollWeightType ParseWeightType(const std::string& value)
4844
//!
4945
uint32_t ParseDurationDays(const std::string& value)
5046
{
51-
try {
52-
return std::stoul(value);
53-
} catch (...) {
47+
uint32_t duration = 0;
48+
49+
if (!::ParseUInt32(value, &duration)) {
5450
return 0;
5551
}
52+
53+
return duration;
5654
}
5755

5856
//!

0 commit comments

Comments
 (0)