Skip to content

Commit 143c73e

Browse files
shukitchanphongn
authored andcommitted
Fix problem with the negation (apache#10971)
1 parent 9466f8b commit 143c73e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/swoc/src/TextView.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ svtoi(TextView src, TextView *out, int base) {
6363
out->assign(start, parsed.data_end());
6464
}
6565
if (neg) {
66-
zret = -intmax_t(std::min<uintmax_t>(n, ABS_MIN));
66+
uintmax_t temp = std::min<uintmax_t>(n, ABS_MIN);
67+
if (temp == ABS_MIN) {
68+
zret = std::numeric_limits<intmax_t>::min();
69+
} else {
70+
zret = -intmax_t(temp);
71+
}
6772
} else {
6873
zret = std::min(n, ABS_MAX);
6974
}

0 commit comments

Comments
 (0)