Skip to content

Commit b3ce57f

Browse files
committed
Improved buffer size for 'EncodeURI'
1 parent d9c9095 commit b3ce57f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/LibJSON.bas

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,7 @@ Public Function EncodeURI(ByRef dataUTF16LE As Variant _
22332233
Dim codepoint As Long
22342234
Dim lowSurrogate As Long
22352235
Dim buff As String
2236+
Dim bLen As Long
22362237
Dim defProp As Variant
22372238
Dim isDefProp As Boolean
22382239
'
@@ -2309,8 +2310,13 @@ Public Function EncodeURI(ByRef dataUTF16LE As Variant _
23092310
'
23102311
i = 0
23112312
j = 1
2312-
buff = Space$(sizeW * 6)
2313+
bLen = sizeW * 2 + 12
2314+
buff = Space$(bLen)
23132315
Do While i < sizeW
2316+
If j + 12 > bLen Then
2317+
buff = buff & Space$(bLen)
2318+
bLen = bLen * 2
2319+
End If
23142320
codepoint = chars.arr(i) And &HFFFF&
23152321
If codepoint >= &HD800& And codepoint <= &HDBFF& Then 'High surrogate
23162322
If i < sizeW - 1 Then

0 commit comments

Comments
 (0)