mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-16 20:17:05 +03:00
[bug] Don't negate a signed number (UB fix)
* Fixes a potential UB in number to string conversion because of
a possible undefined behavior caused by -int64_t(a) code. The
fix replaces the code with Support::neg() function, which was
designed for exactly this.
This commit is contained in:
@@ -291,7 +291,7 @@ Error String::_opNumber(ModifyOp op, uint64_t i, uint32_t base, size_t width, St
|
||||
// -----------
|
||||
|
||||
if (Support::test(flags, StringFormatFlags::kSigned) && int64_t(i) < 0) {
|
||||
i = uint64_t(-int64_t(i));
|
||||
i = Support::neg(i);
|
||||
sign = '-';
|
||||
}
|
||||
else if (Support::test(flags, StringFormatFlags::kShowSign)) {
|
||||
|
||||
Reference in New Issue
Block a user