[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Test for empty array in array_rshift()

From: William Park
Subject: Test for empty array in array_rshift()
Date: Tue, 17 Aug 2004 17:10:19 -0400

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib   -O4 -march=i686
uname output: Linux node1 2.6.7 #4 SMP Thu Jun 17 01:01:26 EDT 2004 i686 
unknown unknown GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 3.0
Patch Level: 0

    Not visible to user.  But, array_rshift() does not test for empty
    array.  So, when right-shifting by N, it happily increases 'max_index'
    by N, while everything else is still empty.  Later on, array_insert()
    can't find place to insert, if index is less than now fictitious N.

    In array_rshift(), file ./array.c,

        array_rshift (a, n, s)
        ARRAY   *a;
        int     n;
        char    *s;
                register ARRAY_ELEMENT  *ae, *new;

-               if (a == 0)
+               if (a == 0 || array_empty(a))
                        return (0);

                if (n <= 0)
                        return (a->num_elements);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]