Prevent unintentional integer overflow in libwc

This commit is contained in:
Tatsuya Kinoshita
2021-02-28 15:57:46 +09:00
parent dcbdb679aa
commit defabca229
2 changed files with 2 additions and 2 deletions

View File

@@ -73,7 +73,7 @@ wc_conv_from_utf7(Str is, wc_ces ces)
;
if (p == ep)
return is;
os = Strnew_size(is->length * 4 / 3);
os = Strnew_size(is->length + is->length / 3);
if (p > sp)
Strcat_charp_n(os, is->ptr, (int)(p - sp));

View File

@@ -150,7 +150,7 @@ wc_conv_from_utf8(Str is, wc_ces ces)
;
if (p == ep)
return is;
os = Strnew_size(is->length * 4 / 3);
os = Strnew_size(is->length + is->length / 3);
if (p > sp)
Strcat_charp_n(os, is->ptr, (int)(p - sp));