projects
/
folly.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d618bf9
)
folly: ubsan: format: avoid UB in abs(-INT_MIN)
author
Lucian Grijincu
<lucian@fb.com>
Wed, 11 May 2016 17:45:33 +0000
(10:45 -0700)
committer
Facebook Github Bot 6
<facebook-github-bot-6-bot@fb.com>
Wed, 11 May 2016 17:50:21 +0000
(10:50 -0700)
Summary:
abs(-INT_MIN) is UB. Avoid it by first casting the number to
its unsigned equivalent and then negating that.
Reviewed By: yfeldblum
Differential Revision:
D3280835
fbshipit-source-id:
40922d686173e6467e15d5a6dc2b62ad718349b5
folly/Format-inl.h
patch
|
blob
|
history
diff --git
a/folly/Format-inl.h
b/folly/Format-inl.h
index 35c0298e14fa0b81f955fad893412d2e390f9608..48125dc5df3529dcc1cb154d1666a62367cf1208 100644
(file)
--- a/
folly/Format-inl.h
+++ b/
folly/Format-inl.h
@@
-443,7
+443,7
@@
class FormatValue<
char sign;
if (std::is_signed<T>::value) {
if (folly::is_negative(val_)) {
- uval =
static_cast<UT>(-
val_);
+ uval =
-static_cast<UT>(
val_);
sign = '-';
} else {
uval = static_cast<UT>(val_);