lib: Fix an array subscript is above array bounds error
authorAndreas Schneider <asn@samba.org>
Wed, 25 Nov 2015 11:20:23 +0000 (12:20 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 30 Nov 2015 23:38:23 +0000 (00:38 +0100)
gcc 5.1.1 complains with:
lib/util/idtree.c:184:15: error: array subscript is above array bounds

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/idtree.c

index 2104c741f3ea0b4e128959149c1a22637b3e7fc3..e2cfcc503157a8eed965690d13bbfeb90e66bd15 100644 (file)
@@ -181,8 +181,13 @@ restart:
         */
        n = id;
        while (p->bitmap == IDR_FULL) {
-               if (!(p = pa[++l]))
+               if (l >= MAX_LEVEL) {
                        break;
+               }
+               p = pa[++l];
+               if (p == NULL) {
+                       break;
+               }
                n = n >> IDR_BITS;
                set_bit((n & IDR_MASK), p->bitmap);
        }