This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
UNIVERSAL::can and UNIVERSAL::isa should return undef when
authorGurusamy Sarathy <gsar@cpan.org>
Tue, 15 Feb 2000 18:35:28 +0000 (18:35 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Tue, 15 Feb 2000 18:35:28 +0000 (18:35 +0000)
given undefined values (from Graham Barr <gbarr@pobox.com>)

p4raw-id: //depot/perl@5109

universal.c

index 1e5a1a0..6ccff2f 100644 (file)
@@ -140,6 +140,10 @@ XS(XS_UNIVERSAL_isa)
        Perl_croak(aTHX_ "Usage: UNIVERSAL::isa(reference, kind)");
 
     sv = ST(0);
+
+    if (!SvOK(sv) || !(SvROK(sv) || SvCUR(sv)))
+       XSRETURN_UNDEF;
+
     name = (char *)SvPV(ST(1),n_a);
 
     ST(0) = boolSV(sv_derived_from(sv, name));
@@ -159,6 +163,10 @@ XS(XS_UNIVERSAL_can)
        Perl_croak(aTHX_ "Usage: UNIVERSAL::can(object-ref, method)");
 
     sv = ST(0);
+
+    if (!SvOK(sv) || !(SvROK(sv) || SvCUR(sv)))
+       XSRETURN_UNDEF;
+
     name = (char *)SvPV(ST(1),n_a);
     rv = &PL_sv_undef;