mirror of
https://github.com/ultrajson/ultrajson.git
synced 2024-05-05 16:06:17 +02:00
Fix undefined behavior in Buffer_AppendLongUnchecked (#606)
This was flagged when running with UBSAN
This commit is contained in:
parent
a967539cdc
commit
0959d18cfa
|
@ -42,6 +42,7 @@ https://opensource.apple.com/source/tcl/tcl-14/tcl/license.terms
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <float.h>
|
||||
|
@ -584,7 +585,13 @@ static void Buffer_AppendIndentUnchecked(JSONObjectEncoder *enc, JSINT32 value)
|
|||
static void Buffer_AppendLongUnchecked(JSONObjectEncoder *enc, JSINT64 value)
|
||||
{
|
||||
char* wstr;
|
||||
JSUINT64 uvalue = (value < 0) ? -value : value;
|
||||
JSUINT64 uvalue;
|
||||
|
||||
if (value == INT64_MIN) {
|
||||
uvalue = INT64_MAX + UINT64_C(1);
|
||||
} else {
|
||||
uvalue = (value < 0) ? -value : value;
|
||||
}
|
||||
|
||||
wstr = enc->offset;
|
||||
#ifdef DEBUG
|
||||
|
|
Loading…
Reference in New Issue