Skip to content

Commit 63da182

Browse files
committed
pp_formline: Use bytes_to_utf8_free_me
This can avoid a malloc
1 parent 729b2ac commit 63da182

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pp_ctl.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,14 +824,14 @@ PP_wrapped(pp_formline, 0, 1)
824824
* item_is_utf8 implies source is utf8.
825825
* if trans, translate certain characters during the copy */
826826
{
827-
U8 *tmp = NULL;
827+
void *free_me = NULL;
828828
STRLEN grow = 0;
829829

830830
SvCUR_set(PL_formtarget,
831831
t - SvPVX_const(PL_formtarget));
832832

833833
if (targ_is_utf8 && !item_is_utf8) {
834-
source = tmp = bytes_to_utf8(source, &to_copy);
834+
source = bytes_to_utf8_free_me(source, &to_copy, &free_me);
835835
grow = to_copy;
836836
} else {
837837
if (item_is_utf8 && !targ_is_utf8) {
@@ -883,8 +883,7 @@ PP_wrapped(pp_formline, 0, 1)
883883

884884
t += to_copy;
885885
SvCUR_set(PL_formtarget, SvCUR(PL_formtarget) + to_copy);
886-
if (tmp)
887-
Safefree(tmp);
886+
Safefree(free_me);
888887
break;
889888
}
890889

0 commit comments

Comments
 (0)