Fix undefined behavior in ll2string().
The bug was found by @CAFxX, thanks! See issue #1940.
This commit is contained in:
parent
636ef842de
commit
ca7d9f42b3
@ -261,7 +261,11 @@ int ll2string(char* dst, size_t dstlen, long long svalue) {
|
|||||||
/* The main loop works with 64bit unsigned integers for simplicity, so
|
/* The main loop works with 64bit unsigned integers for simplicity, so
|
||||||
* we convert the number here and remember if it is negative. */
|
* we convert the number here and remember if it is negative. */
|
||||||
if (svalue < 0) {
|
if (svalue < 0) {
|
||||||
|
if (svalue != LLONG_MIN) {
|
||||||
value = -svalue;
|
value = -svalue;
|
||||||
|
} else {
|
||||||
|
value = ((unsigned long long) LLONG_MAX)+1;
|
||||||
|
}
|
||||||
negative = 1;
|
negative = 1;
|
||||||
} else {
|
} else {
|
||||||
value = svalue;
|
value = svalue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user