From 8f7900ee8f72f4d8e8f66818f188834469018006 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 4 Jul 2013 12:24:40 +0200 Subject: [PATCH] statedb: Make sure we call sqlite3_close on a valid pointer. --- src/csync_statedb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/csync_statedb.c b/src/csync_statedb.c index 434033899..1b1af789a 100644 --- a/src/csync_statedb.c +++ b/src/csync_statedb.c @@ -146,10 +146,10 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) { int rc = -1; c_strlist_t *result = NULL; char *statedb_tmp = NULL; - sqlite3 *db; + sqlite3 *db = NULL; - if (_csync_statedb_check(statedb) < 0) { - rc = -1; + rc = _csync_statedb_check(statedb); + if (rc < 0) { goto out; } @@ -159,13 +159,14 @@ int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb) { * The intention is that if something goes wrong we will not loose the * statedb. */ - if (asprintf(&statedb_tmp, "%s.ctmp", statedb) < 0) { + rc = asprintf(&statedb_tmp, "%s.ctmp", statedb); + if (rc < 0) { rc = -1; goto out; } - if (c_copy(statedb, statedb_tmp, 0644) < 0) { - rc = -1; + rc = c_copy(statedb, statedb_tmp, 0644); + if (rc < 0) { goto out; }