mirror of https://github.com/alibaba/fastjson2.git
fix: use absolute value for scale in minCapacity calculation in JSONWriterUTF8 and JSONWriterUTF16 otherwise buffer may overflow
This commit is contained in:
parent
229fab094a
commit
e3eebee8be
|
|
@ -1061,7 +1061,7 @@ class JSONWriterUTF16
|
|||
boolean writeAsString = isWriteAsString(value, features);
|
||||
|
||||
int off = this.off;
|
||||
int minCapacity = off + precision + value.scale() + 7;
|
||||
int minCapacity = off + precision + Math.abs(value.scale()) + 7;
|
||||
char[] chars = this.chars;
|
||||
if (minCapacity > chars.length) {
|
||||
chars = grow(minCapacity);
|
||||
|
|
|
|||
|
|
@ -2387,7 +2387,7 @@ final class JSONWriterUTF8
|
|||
boolean writeAsString = isWriteAsString(value, features);
|
||||
|
||||
int off = this.off;
|
||||
int minCapacity = off + precision + value.scale() + 7;
|
||||
int minCapacity = off + precision + Math.abs(value.scale()) + 7;
|
||||
byte[] bytes = this.bytes;
|
||||
if (minCapacity > bytes.length) {
|
||||
bytes = grow(minCapacity);
|
||||
|
|
|
|||
Loading…
Reference in New Issue