This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
av_fetch(): use AvFILLp rather than AvFILL
authorDavid Mitchell <davem@iabyn.com>
Wed, 17 Aug 2016 08:52:48 +0000 (09:52 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 17 Aug 2016 12:38:56 +0000 (13:38 +0100)
The point in the code which uses AvFILL will never be reached if the array
is tied, so use AvFILLp insead, which directly accesses the xav_fill
field.

This only affects the $a[-N] branch: the $a[+N] branch already uses
AvFILLp().

av.c

diff --git a/av.c b/av.c
index 2f81971..a48702b 100644 (file)
--- a/av.c
+++ b/av.c
@@ -269,7 +269,7 @@ Perl_av_fetch(pTHX_ AV *av, SSize_t key, I32 lval)
     }
 
     if (key < 0) {
-       key += AvFILL(av) + 1;
+       key += AvFILLp(av) + 1;
        if (key < 0)
            return NULL;
     }