diff --git a/sasldb/db_gdbm.c b/sasldb/db_gdbm.c --- a/sasldb/db_gdbm.c +++ b/sasldb/db_gdbm.c @@ -107,17 +107,19 @@ int _sasldb_getdata(const sasl_utils_t *utils, gkey.dptr = key; gkey.dsize = key_len; gvalue = gdbm_fetch(db, gkey); + int fetch_errno = gdbm_errno; + gdbm_close(db); if (! gvalue.dptr) { - if (gdbm_errno == GDBM_ITEM_NOT_FOUND) { + if (fetch_errno == GDBM_ITEM_NOT_FOUND) { utils->seterror(conn, SASL_NOLOG, "user: %s@%s property: %s not found in %s", authid, realm, propName, path); result = SASL_NOUSER; } else { utils->seterror(conn, 0, - "Couldn't fetch entry from %s: gdbm_errno=%d", - path, gdbm_errno); + "Couldn't fetch entry from %s: gdbm_errno=%d, authid=%s, realm=%s, propName=%s", + path, fetch_errno, authid, realm, propName); result = SASL_FAIL; } goto cleanup;