From: Gurusamy Sarathy Date: Mon, 24 Apr 2000 08:08:59 +0000 (+0000) Subject: avoid using uninitialized memory in require version check X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4305d8abee2315e02cb395dec9deede4e7f9f179;p=p5sagit%2Fp5-mst-13.2.git avoid using uninitialized memory in require version check p4raw-id: //depot/perl@5924 --- diff --git a/pp_ctl.c b/pp_ctl.c index 7a2eb20..e77901d 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2916,8 +2916,8 @@ PP(pp_require) sv = POPs; if (SvNIOKp(sv)) { - UV rev, ver, sver; - if (SvPOKp(sv)) { /* require v5.6.1 */ + if (SvPOK(sv) && SvNOK(sv)) { /* require v5.6.1 */ + UV rev = 0, ver = 0, sver = 0; I32 len; U8 *s = (U8*)SvPVX(sv); U8 *end = (U8*)SvPVX(sv) + SvCUR(sv); @@ -2929,14 +2929,8 @@ PP(pp_require) s += len; if (s < end) sver = utf8_to_uv(s, &len); - else - sver = 0; } - else - ver = 0; } - else - rev = 0; if (PERL_REVISION < rev || (PERL_REVISION == rev && (PERL_VERSION < ver @@ -2947,6 +2941,7 @@ PP(pp_require) "v%d.%d.%d, stopped", rev, ver, sver, PERL_REVISION, PERL_VERSION, PERL_SUBVERSION); } + RETPUSHYES; } else if (!SvPOKp(sv)) { /* require 5.005_03 */ if ((NV)PERL_REVISION + ((NV)PERL_VERSION/(NV)1000) @@ -2975,8 +2970,8 @@ PP(pp_require) PERL_SUBVERSION); } } + RETPUSHYES; } - RETPUSHYES; } name = SvPV(sv, len); if (!(name && len > 0 && *name)) diff --git a/universal.c b/universal.c index 9adc42d..6c555a1 100644 --- a/universal.c +++ b/universal.c @@ -262,7 +262,7 @@ XS(XS_UNIVERSAL_VERSION) break; } if (len) { - if (SvNIOKp(req) && SvPOK(req)) { + if (SvNOK(req) && SvPOK(req)) { /* they said C and $Foo::VERSION * doesn't look like a float: do string compare */ if (sv_cmp(req,sv) == 1) { @@ -283,7 +283,7 @@ XS(XS_UNIVERSAL_VERSION) /* if we get here, we're looking for a numeric comparison, * so force the required version into a float, even if they * said C */ - if (SvNIOKp(req) && SvPOK(req)) { + if (SvNOK(req) && SvPOK(req)) { NV n = SvNV(req); req = sv_newmortal(); sv_setnv(req, n);