s3:cclean: fix memory allocation
authorGregor Beck <gbeck@sernet.de>
Fri, 29 Jun 2012 09:36:54 +0000 (11:36 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 29 Jun 2012 13:21:23 +0000 (15:21 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
source3/utils/cclean.c

index b035d33c031569a6b7492e57adb0e46b555655b1..d98725e7fb4fcc7c4137ce3ad0987236f39585b6 100644 (file)
@@ -66,7 +66,7 @@ static int read_connections_fn(const struct connections_key *key,
        struct cclean_ctx *ctx = (struct cclean_ctx *)cclean_ctx;
        unsigned length = talloc_array_length(ctx->cnums);
        if (length <= ctx->num) {
-               int n = 2*length;
+               int n = MAX(2*length, 16);
                void *tmp;
 
                tmp = talloc_realloc(ctx, ctx->ids, struct server_id, n);
@@ -95,7 +95,7 @@ static int read_connections_fn(const struct connections_key *key,
        ctx->ids[ctx->num] = key->pid;
        ctx->cnums[ctx->num] = key->cnum;
        ctx->names[ctx->num] = talloc_strndup(ctx, key->name, FSTRING_LEN);
-       if (ctx->names[ctx->num]) {
+       if (ctx->names[ctx->num] == NULL) {
                goto talloc_failed;
        }
        ctx->num++;