diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-10-08 16:56:50 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-10-08 16:58:10 +0100 |
commit | 8a280620fcbbc5f0c47b80ca2dc5d3eb208012ae (patch) | |
tree | de23eb40341be025d078c4f68e5727c82cfcfed2 | |
parent | 379a89070cf5bdcfa33b12551d2c9ef0a3e11418 (diff) | |
download | perl-8a280620fcbbc5f0c47b80ca2dc5d3eb208012ae.tar.gz |
Refactor Perl_xs_apiversion_bootcheck()
Use fewer mortals, and avoid leaking an SV if upg_version() croaks.
-rw-r--r-- | util.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -6519,21 +6519,26 @@ Perl_xs_apiversion_bootcheck(pTHX_ SV *module, const char *api_p, STRLEN api_len) { SV *xpt = NULL; - SV *compver = Perl_newSVpvn(aTHX_ api_p, api_len); - SV *runver = new_version(PL_apiversion); + SV *compver = Perl_newSVpvn_flags(aTHX_ api_p, api_len, SVs_TEMP); + SV *runver; PERL_ARGS_ASSERT_XS_APIVERSION_BOOTCHECK; + /* This might croak */ compver = upg_version(compver, 0); + /* This should never croak */ + runver = new_version(PL_apiversion); if (vcmp(compver, runver)) { + SV *compver_string = vstringify(compver); + SV *runver_string = vstringify(runver); xpt = Perl_newSVpvf(aTHX_ "Perl API version %"SVf - " of %s does not match %"SVf, - SVfARG(Perl_sv_2mortal(aTHX_ vstringify(compver))), - SvPV_nolen_const(module), - SVfARG(Perl_sv_2mortal(aTHX_ vstringify(runver)))); + " of %"SVf" does not match %"SVf, + compver_string, module, runver_string); Perl_sv_2mortal(aTHX_ xpt); + + SvREFCNT_dec(compver_string); + SvREFCNT_dec(runver_string); } - SvREFCNT_dec(compver); SvREFCNT_dec(runver); if (xpt) Perl_croak_sv(aTHX_ xpt); |