Skip Menu |

This queue is for tickets about the List-MoreUtils CPAN distribution.

Report information
The Basics
Id: 75727
Status: resolved
Priority: 0/
Queue: List-MoreUtils

People
Owner: Nobody in particular
Requestors: kato.kazuyoshi [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.33
Fixed in: 0.414_001



Subject: List::MoreUtils::after's XS implementation call XSRETURN(-1) when it doesn't find an element
I noticed that List::MoreUtils::after can corrupt memory when it doesn't find an element from a list. List::MoreUtils::after's XS implementation have a loop for (i = 1; i < items; i++) { GvSV(PL_defgv) = args[i]; MULTICALL; if (SvTRUE(*PL_stack_sp)) { break; } } and XSRETURN(items-i-1); However, if it can't find an element on the loop, XSRETURN(items-i-1) became XSRETURN(-1). In this patch, I added XSRETURN_EMPTY after the loop to fix this problem.
Subject: after.diff
diff --git a/MoreUtils.xs b/MoreUtils.xs index 5abed72..e14bb42 100644 --- a/MoreUtils.xs +++ b/MoreUtils.xs @@ -640,6 +640,9 @@ CODE: POP_MULTICALL; + if (i == items) /* the above loop didn't find an element */ + XSRETURN_EMPTY; + for (j = i + 1; j < items; ++j) args[j-i-1] = args[j];
Seems to be fixed since ages :/
On Mon Mar 09 09:52:27 2015, REHSACK wrote: Show quoted text
> Seems to be fixed since ages :/
No, you still get negative arguments to XSRETURN by using your testsuite. See https://github.com/perl5-utils/List-MoreUtils/pull/13 -- Reini Urban
Fixing commits from PR#13 and PR#17 are cherry-picked and will be included in next release.