r14308: fixed an out of range shift and an uninitialised error
authorAndrew Tridgell <tridge@samba.org>
Mon, 13 Mar 2006 06:58:09 +0000 (06:58 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:57:10 +0000 (13:57 -0500)
(This used to be commit 9acc445a21b7f04eb980a05109f2c73d58221f1a)

source4/lib/util/idtree.c

index d29c3b8fbdc307d354599e1f4d9bf0586fbc06c5..c02a2636a1ae54bd720c0b96951e6a2f5b00958d 100644 (file)
@@ -107,6 +107,8 @@ static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id)
        int l, id;
        uint32_t bm;
 
+       memset(pa, 0, sizeof(pa));
+
        id = *starting_id;
        p = idp->top;
        l = idp->layers;
@@ -271,7 +273,7 @@ static void *_idr_find(struct idr_context *idp, int id)
        /* Mask off upper bits we don't use for the search. */
        id &= MAX_ID_MASK;
 
-       while (n > 0 && p) {
+       while (n >= IDR_BITS && p) {
                n -= IDR_BITS;
                p = p->ary[(id >> n) & IDR_MASK];
        }