Skip to content

Commit

Permalink
utf8::upgrade: Don't coerce undef arg
Browse files Browse the repository at this point in the history
This fixes GH Perl#20419
  • Loading branch information
khwilliamson committed Nov 2, 2022
1 parent fce4124 commit 6bdaa52
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions universal.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,21 @@ XS(XS_utf8_upgrade)
croak_xs_usage(cv, "sv");
else {
SV * const sv = ST(0);
STRLEN RETVAL;
STRLEN RETVAL = 0;
dXSTARG;

RETVAL = sv_utf8_upgrade(sv);
XSprePUSH; PUSHi((IV)RETVAL);
XSprePUSH;
if (LIKELY(sv)) {
SvGETMAGIC(sv);
if (LIKELY(SvOK(sv))) {
RETVAL = sv_utf8_upgrade_nomg(sv);
PUSHi( (IV) RETVAL);
} else {
PUSHs(newSV(0));
}
} else {
PUSHs(newSV(0));
}
}
XSRETURN(1);
}
Expand Down

0 comments on commit 6bdaa52

Please sign in to comment.