This is an automated email from the ASF dual-hosted git repository.
kichan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new dc4dc35780 Fix problem with the negation (#10971)
dc4dc35780 is described below
commit dc4dc35780a923fbe8759994f481250b8486a505
Author: Kit Chan <[email protected]>
AuthorDate: Sun Jan 14 00:25:36 2024 -0800
Fix problem with the negation (#10971)
---
lib/swoc/src/TextView.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/swoc/src/TextView.cc b/lib/swoc/src/TextView.cc
index fbfb343106..5e6cd74911 100644
--- a/lib/swoc/src/TextView.cc
+++ b/lib/swoc/src/TextView.cc
@@ -63,7 +63,12 @@ svtoi(TextView src, TextView *out, int base) {
out->assign(start, parsed.data_end());
}
if (neg) {
- zret = -intmax_t(std::min<uintmax_t>(n, ABS_MIN));
+ uintmax_t temp = std::min<uintmax_t>(n, ABS_MIN);
+ if (temp == ABS_MIN) {
+ zret = std::numeric_limits<intmax_t>::min();
+ } else {
+ zret = -intmax_t(temp);
+ }
} else {
zret = std::min(n, ABS_MAX);
}