mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Avoid unary negation of INT64_MIN in modp_litoa10
Overlow can occur in that case, which is undefined behavior.
This commit is contained in:
parent
d25ead8f8e
commit
17e3392052
1 changed files with 1 additions and 1 deletions
|
@ -57,7 +57,7 @@ void modp_uitoa10(uint32_t value, char* str)
|
|||
void modp_litoa10(int64_t value, char* str)
|
||||
{
|
||||
char* wstr=str;
|
||||
uint64_t uvalue = (value < 0) ? -value : value;
|
||||
uint64_t uvalue = (value < 0) ? (value == INT64_MIN ? (uint64_t)(INT64_MAX) + 1 : -value) : value;
|
||||
|
||||
// Conversion. Number is reversed.
|
||||
do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue