diff options
-rw-r--r-- | source4/lib/util/idtree.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source4/lib/util/idtree.c b/source4/lib/util/idtree.c index d29c3b8fbd..c02a2636a1 100644 --- a/source4/lib/util/idtree.c +++ b/source4/lib/util/idtree.c @@ -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]; } |