From: Hallvard Furuseth Date: Sun, 5 May 2013 13:13:31 +0000 (+0200) Subject: ITS#7515 Fix nested transaction error handling. X-Git-Tag: OPENLDAP_REL_ENG_2_4_36~68^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2d6aed75375cd9c3231130ddcdbd9f685f953029;p=openldap ITS#7515 Fix nested transaction error handling. mdb_txn_begin(): Do not free(mt_free_pgs), it needs mdb_midl_free(). mdb_txn_commit(): Catch commit(child) error. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index c8ef564d75..2a7ca54d83 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -1939,14 +1939,11 @@ mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **ret) if (parent) { unsigned int i; - txn->mt_free_pgs = mdb_midl_alloc(); - if (!txn->mt_free_pgs) { - free(txn); - return ENOMEM; - } txn->mt_u.dirty_list = malloc(sizeof(MDB_ID2)*MDB_IDL_UM_SIZE); - if (!txn->mt_u.dirty_list) { - free(txn->mt_free_pgs); + if (!txn->mt_u.dirty_list || + !(txn->mt_free_pgs = mdb_midl_alloc())) + { + free(txn->mt_u.dirty_list); free(txn); return ENOMEM; } @@ -2138,8 +2135,12 @@ mdb_txn_commit(MDB_txn *txn) assert(txn->mt_env != NULL); if (txn->mt_child) { - mdb_txn_commit(txn->mt_child); + rc = mdb_txn_commit(txn->mt_child); txn->mt_child = NULL; + if (rc) { + mdb_txn_abort(txn); + return rc; + } } env = txn->mt_env;