From 1562ecf221d9f5f591e344d6e5c6f19e802b089e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 8 Mar 2006 07:20:10 +0000 Subject: r14029: Fix resource leak in error codepath. Coverity CID #64. Jeremy. (This used to be commit d2e9d5b34baee90060ee9131b3da903309625a56) --- source4/lib/tdb/common/traverse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c index dc1060c6d0..4792af1122 100644 --- a/source4/lib/tdb/common/traverse.c +++ b/source4/lib/tdb/common/traverse.c @@ -289,10 +289,14 @@ TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA oldkey) rec.key_len)) || memcmp(k, oldkey.dptr, oldkey.dsize) != 0) { /* No, it wasn't: unlock it and start from scratch */ - if (tdb_unlock_record(tdb, tdb->travlocks.off) != 0) + if (tdb_unlock_record(tdb, tdb->travlocks.off) != 0) { + SAFE_FREE(k); return tdb_null; - if (tdb_unlock(tdb, tdb->travlocks.hash, F_WRLCK) != 0) + } + if (tdb_unlock(tdb, tdb->travlocks.hash, F_WRLCK) != 0) { + SAFE_FREE(k); return tdb_null; + } tdb->travlocks.off = 0; } -- cgit