dbwrap_cache: Fix dbwrap_cache_validate
authorVolker Lendecke <vl@samba.org>
Sat, 7 Dec 2013 12:58:07 +0000 (12:58 +0000)
committerStefan Metzmacher <metze@samba.org>
Sat, 14 Dec 2013 09:10:07 +0000 (10:10 +0100)
Classic brown paper bag bug :-(

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/dbwrap/dbwrap_cache.c

index d97242ebdc87f53442bd622fe11acdd1a1b0b0da..6c6b795a416798ce5605a91141ac915839fb4ee1 100644 (file)
@@ -32,15 +32,27 @@ struct db_cache_ctx {
 
 static bool dbwrap_cache_validate(struct db_cache_ctx *ctx)
 {
-       if (ctx->seqnum == dbwrap_get_seqnum(ctx->backing)) {
+       int backing_seqnum;
+
+       backing_seqnum = dbwrap_get_seqnum(ctx->backing);
+       if (backing_seqnum == ctx->seqnum) {
                return true;
        }
+
        TALLOC_FREE(ctx->positive);
        ctx->positive = db_open_rbt(ctx);
+       if (ctx->positive == NULL) {
+               return false;
+       }
+
        TALLOC_FREE(ctx->negative);
        ctx->negative = db_open_rbt(ctx);
+       if (ctx->negative == NULL) {
+               return false;
+       }
 
-       return ((ctx->positive != NULL) && (ctx->negative != NULL));
+       ctx->seqnum = backing_seqnum;
+       return true;
 }
 
 static NTSTATUS dbwrap_cache_parse_record(