From: Howard Chu Date: Wed, 24 Aug 2011 13:36:21 +0000 (-0700) Subject: Plug memleak X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b925b3504586c061cdb49411e392a109c71e10a7;p=thirdparty%2Fopenldap.git Plug memleak --- diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c index f3dcfe0b3b..82ec07b7f1 100644 --- a/servers/slapd/back-mdb/dn2id.c +++ b/servers/slapd/back-mdb/dn2id.c @@ -310,10 +310,8 @@ mdb_dn2id( data.mv_data = d; rc = mdb_cursor_get( cursor, &key, &data, MDB_GET_BOTH ); op->o_tmpfree( d, op->o_tmpmemctx ); - if ( rc ) { - mdb_cursor_close( cursor ); + if ( rc ) break; - } ptr = (char *) data.mv_data + data.mv_size - sizeof(ID); memcpy( &nid, ptr, sizeof(ID)); @@ -343,6 +341,7 @@ mdb_dn2id( } } *id = nid; + mdb_cursor_close( cursor ); if ( matched && matched->bv_len ) { ptr = op->o_tmpalloc( matched->bv_len+1, op->o_tmpmemctx ); strcpy( ptr, matched->bv_val );