Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pp_syswrite: Use new utf8_to_bytes_temp_pv() #22795

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions pp_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,6 @@ PP_wrapped(pp_syswrite, 0, 1)
STRLEN blen;
const int op_type = PL_op->op_type;
bool doing_utf8;
U8 *tmpbuf = NULL;
GV *const gv = MUTABLE_GV(*++MARK);
IO *const io = GvIO(gv);
int fd;
Expand Down Expand Up @@ -2242,15 +2241,10 @@ PP_wrapped(pp_syswrite, 0, 1)
OP_DESC(PL_op));
}
else if (doing_utf8) {
STRLEN tmplen = blen;
U8 * const result = bytes_from_utf8((const U8*) buffer, &tmplen, &doing_utf8);
if (!doing_utf8) {
tmpbuf = result;
buffer = (char *) tmpbuf;
blen = tmplen;
if (utf8_to_bytes_temp_pv((const U8**)&buffer, &blen)) {
doing_utf8 = false;
}
else {
assert((char *)result == buffer);
Perl_croak(aTHX_ "Wide character in %s", OP_DESC(PL_op));
}
}
Expand Down Expand Up @@ -2283,7 +2277,6 @@ PP_wrapped(pp_syswrite, 0, 1)
length = (Size_t)SvIVx(*++MARK);
#endif
if ((SSize_t)length < 0) {
Safefree(tmpbuf);
DIE(aTHX_ "Negative length");
}
}
Expand All @@ -2292,12 +2285,10 @@ PP_wrapped(pp_syswrite, 0, 1)
offset = SvIVx(*++MARK);
if (offset < 0) {
if (-offset > (IV)blen) {
Safefree(tmpbuf);
DIE(aTHX_ "Offset outside string");
}
offset += blen;
} else if (offset > (IV)blen) {
Safefree(tmpbuf);
DIE(aTHX_ "Offset outside string");
}
} else
Expand All @@ -2322,7 +2313,6 @@ PP_wrapped(pp_syswrite, 0, 1)
goto say_undef;
SP = ORIGMARK;

Safefree(tmpbuf);
#if Size_t_size > IVSIZE
PUSHn(retval);
#else
Expand All @@ -2331,7 +2321,6 @@ PP_wrapped(pp_syswrite, 0, 1)
RETURN;

say_undef:
Safefree(tmpbuf);
SP = ORIGMARK;
RETPUSHUNDEF;
}
Expand Down
Loading