summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorJohn Peacock <jpeacock@cpan.org>2013-09-02 18:49:50 -0400
committerSteve Hay <steve.m.hay@googlemail.com>2013-09-03 08:29:15 +0100
commit0c1d6ad7c56336f44f5ca9213891dc048565bb49 (patch)
tree74487d739e774eff720c376e9142d135111061d8 /universal.c
parentdb76cb3c1e2e7b3cb18b6ea4cef832197fd90c8e (diff)
downloadperl-0c1d6ad7c56336f44f5ca9213891dc048565bb49.tar.gz
Sync core with CPAN version.pm release
Remove pointless diag lines, which were more trouble than they were worth. Add code to ensure that SV's with magic are handled properly, and include a test for it as well. A couple of whitespace changes and one last set of I32 -> SSize_t upgrade for array indices.
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/universal.c b/universal.c
index 847de55b03..8337e2b4e0 100644
--- a/universal.c
+++ b/universal.c
@@ -508,6 +508,10 @@ XS(XS_version_new)
STRLEN len;
const char *classname;
U32 flags;
+
+ /* Just in case this is something like a tied hash */
+ SvGETMAGIC(vs);
+
if ( sv_isobject(ST(0)) ) { /* get the class if called as an object method */
const HV * stash = SvSTASH(SvRV(ST(0)));
classname = HvNAME(stash);
@@ -725,8 +729,14 @@ XS(XS_version_qv)
STRLEN len = 0;
const char * classname = "";
U32 flags = 0;
- if ( items == 2 && SvOK(ST(1)) ) {
- ver = ST(1);
+ if ( items == 2 ) {
+ SvGETMAGIC(ST(1));
+ if (SvOK(ST(1))) {
+ ver = ST(1);
+ }
+ else {
+ Perl_croak(aTHX_ "Invalid version format (version required)");
+ }
if ( sv_isobject(ST(0)) ) { /* class called as an object method */
const HV * stash = SvSTASH(SvRV(ST(0)));
classname = HvNAME(stash);