summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-04-19 10:27:07 +0200
committerVolker Lendecke <vl@samba.org>2012-04-19 17:37:37 +0200
commit85c1e895a5b4d520481de419aff04c2519198894 (patch)
tree4c5e891e5597150ac21ffe00d44d995bf2a117a0 /source3/lib
parent8173331150482b78e85c005fcea2c7d80f430f65 (diff)
downloadsamba-85c1e895a5b4d520481de419aff04c2519198894.tar.gz
samba-85c1e895a5b4d520481de419aff04c2519198894.tar.bz2
samba-85c1e895a5b4d520481de419aff04c2519198894.zip
s3: Fix Coverity ID 2745 and 2746: FORWARD_NULL
We can assume that the rbt dbs are around
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap/dbwrap_cache.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/source3/lib/dbwrap/dbwrap_cache.c b/source3/lib/dbwrap/dbwrap_cache.c
index ded85258a3..e0fced591b 100644
--- a/source3/lib/dbwrap/dbwrap_cache.c
+++ b/source3/lib/dbwrap/dbwrap_cache.c
@@ -30,15 +30,17 @@ struct db_cache_ctx {
struct db_context *negative;
};
-static void dbwrap_cache_validate(struct db_cache_ctx *ctx)
+static bool dbwrap_cache_validate(struct db_cache_ctx *ctx)
{
if (ctx->seqnum == dbwrap_get_seqnum(ctx->backing)) {
- return;
+ return true;
}
TALLOC_FREE(ctx->positive);
ctx->positive = db_open_rbt(ctx);
TALLOC_FREE(ctx->negative);
ctx->negative = db_open_rbt(ctx);
+
+ return ((ctx->positive != NULL) && (ctx->negative != NULL));
}
static NTSTATUS dbwrap_cache_parse_record(
@@ -51,16 +53,15 @@ static NTSTATUS dbwrap_cache_parse_record(
TDB_DATA value;
NTSTATUS status;
- dbwrap_cache_validate(ctx);
+ if (!dbwrap_cache_validate(ctx)) {
+ return NT_STATUS_NO_MEMORY;
+ }
- if (ctx->positive != NULL) {
- status = dbwrap_parse_record(
- ctx->positive, key, parser, private_data);
- if (NT_STATUS_IS_OK(status)) {
- return status;
- }
+ status = dbwrap_parse_record(ctx->positive, key, parser, private_data);
+ if (NT_STATUS_IS_OK(status)) {
+ return status;
}
- if ((ctx->negative != NULL) && dbwrap_exists(ctx->negative, key)) {
+ if (dbwrap_exists(ctx->negative, key)) {
return NT_STATUS_NOT_FOUND;
}
@@ -191,7 +192,10 @@ struct db_context *db_open_cache(TALLOC_CTX *mem_ctx,
ctx->seqnum = -1;
ctx->backing = talloc_move(ctx, &backing);
db->private_data = ctx;
- dbwrap_cache_validate(ctx);
+ if (!dbwrap_cache_validate(ctx)) {
+ TALLOC_FREE(db);
+ return NULL;
+ }
db->fetch_locked = dbwrap_cache_fetch_locked;
db->try_fetch_locked = NULL;