Pārlūkot izejas kodu

Tighten string buffer size calculation in enc_string.

When "\u"-escaping a Unicode character, the esc_extra value doesn't
need to include the number of bytes in the input string.  That is, if
a three-byte UTF-8 character is being escaped to a six-byte "\uXXXX"
sequence, esc_extra only needs to be increased by 3.
pull/156/head
David Hull pirms 7 gadiem
vecāks
revīzija
0e721a7e5e
1 mainītis faili ar 1 papildinājumiem un 4 dzēšanām
  1. +1
    -4
      c_src/encoder.c

+ 1
- 4
c_src/encoder.c Parādīt failu

@ -307,10 +307,7 @@ enc_string(Encoder* e, ERL_NIF_TERM val)
if(uval < 0) {
return 0;
}
esc_extra += utf8_esc_len(uval);
if(ulen < 0) {
return 0;
}
esc_extra += utf8_esc_len(uval) - ulen;
}
i += ulen;
}

Notiek ielāde…
Atcelt
Saglabāt