diff options
author | Karl Williamson <khw@cpan.org> | 2022-10-28 08:48:37 -0600 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2022-11-14 10:29:48 +0100 |
commit | 347a477c264548540487606c624445883c79c135 (patch) | |
tree | 0957e5aab296861fe1992a1098b546fd325ce168 /universal.c | |
parent | a503b7406f4be5b6577fc63261184ffbe58009a1 (diff) | |
download | perl-347a477c264548540487606c624445883c79c135.tar.gz |
utf8::upgrade: Don't coerce undef arg
This fixes GH #20419
Diffstat (limited to 'universal.c')
-rw-r--r-- | universal.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/universal.c b/universal.c index 119117e818..20a36fae85 100644 --- a/universal.c +++ b/universal.c @@ -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 (UNLIKELY(! sv)) { + XSRETURN_UNDEF; + } + + SvGETMAGIC(sv); + if (UNLIKELY(! SvOK(sv))) { + XSRETURN_UNDEF; + } + + RETVAL = sv_utf8_upgrade_nomg(sv); + PUSHi( (IV) RETVAL); } XSRETURN(1); } |