Skip to content

Commit fe76e18

Browse files
authored
Merge pull request Perl#9 from haarg/fix-vcmp-stack
fix stack usage in vcmp method (cmp overload)
2 parents 454a163 + 0bbfa03 commit fe76e18

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

t/01base.t

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ ok defined($v), 'Fix for RT #47980';
4747
like $@, qr'Usage: version::new\(class, version\)',
4848
'No implicit object creation when called as function';
4949
}
50+
51+
{
52+
eval { version::vcmp($^V) };
53+
like $@, qr{Usage: version::\S+\(lobj, robj, \.\.\.\)},
54+
'vcmp method throws error on single argument';
55+
}

vutil/vxs.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ VXS(version_normal)
312312
VXS(version_vcmp)
313313
{
314314
dXSARGS;
315-
if (items < 1)
316-
croak_xs_usage(cv, "lobj, ...");
315+
if (items < 2)
316+
croak_xs_usage(cv, "lobj, robj, ...");
317317
SP -= items;
318318
{
319319
SV * lobj;
@@ -322,7 +322,7 @@ VXS(version_vcmp)
322322
SV *rs;
323323
SV *rvs;
324324
SV * robj = ST(1);
325-
const IV swap = (IV)SvIV(ST(2));
325+
const int swap = items > 2 ? SvTRUE(ST(2)) : 0;
326326

327327
if ( !ISA_VERSION_OBJ(robj) )
328328
{

0 commit comments

Comments
 (0)