Skip to content

Commit a46ede0

Browse files
committed
fix stack usage in vcmp method (cmp overload)
1 parent 454a163 commit a46ede0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
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, \.\.\.\)},
54+
'vcmp method throws error on single argument';
55+
}

vutil/vxs.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ VXS(version_normal)
312312
VXS(version_vcmp)
313313
{
314314
dXSARGS;
315-
if (items < 1)
315+
if (items < 2)
316316
croak_xs_usage(cv, "lobj, ...");
317317
SP -= items;
318318
{
@@ -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)