Procházet zdrojové kódy

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 před 7 roky
rodič
revize
0e721a7e5e
1 změnil soubory, kde provedl 1 přidání a 4 odebrání
  1. +1
    -4
      c_src/encoder.c

+ 1
- 4
c_src/encoder.c Zobrazit soubor

@ -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;
}

Načítá se…
Zrušit
Uložit