Bug#532534: liblist-moreutils-perl: minmax() one arg access below stack

Kevin Ryde user42 at zip.com.au
Tue Jun 9 21:26:25 UTC 2009


Package: liblist-moreutils-perl
Version: 0.22-1+b1
Severity: normal
Tags: patch

The program foo.pl below gets errors

    Use of uninitialized value in subroutine entry at foo.pl line 5.
    Use of uninitialized value $min in concatenation (.) or string at foo.pl line 6.

where I hoped minmax() would return 100 for both minimum and maximum
when called with one arg.


I think the xsub for minmax() when with just one arg, ie. items==1,
accesses an item below its args on the stack.  In the code

	if (items & 1) {
            asv = ST(items-2);

the ST(items-2) is ST(-1).  No doubt what's there depends on the calling
context or something.  foo.pl seems to see an undef, in one of my
programs I struck "non-numeric" warnings for hitting an alphabetic
string.

Perhaps items==1 can shortcut to the end of the func like below.  The
ref counting is right just duplicating an existing arg, is it?

I think EXTEND(SP,2) is certainly needed though, the code shouldn't
store ST(1) at the end unless either items>=2 or an EXTEND.

Incidentally, the corresponding code in the pure-perl implementation is
ok because of course there $_[-1] on a length-one @_ means $_[0].


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i586)

Kernel: Linux 2.6.26-1-486
Locale: LANG=en_AU, LC_CTYPE=en_AU (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages liblist-moreutils-perl depends on:
ii  libc6                         2.9-13     GNU C Library: Shared libraries
ii  perl                          5.10.0-22  Larry Wall's Practical Extraction 
ii  perl-base [perlapi-5.10.0]    5.10.0-22  minimal Perl system

liblist-moreutils-perl recommends no packages.

liblist-moreutils-perl suggests no packages.

-- no debconf information

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.pl
Type: text/x-perl
Size: 109 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-perl-maintainers/attachments/20090610/73d25f83/attachment-0001.pl>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MoreUtils.xs.minmax-one.diff
Type: text/x-diff
Size: 421 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-perl-maintainers/attachments/20090610/73d25f83/attachment-0001.diff>


More information about the pkg-perl-maintainers mailing list