]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Check in both commitTransaction and abortTransaction whether a transaction is actuall... 10099/head
authorRobin Geuze <robing@transip.nl>
Wed, 17 Feb 2021 13:10:04 +0000 (14:10 +0100)
committerRobin Geuze <robing@transip.nl>
Wed, 17 Feb 2021 13:10:04 +0000 (14:10 +0100)
modules/lmdbbackend/lmdbbackend.cc

index 158429460f36d208ef75342e1f53f8f689bbb6b7..c2fa92deb1b9a34bc5109da25822e9f8028db764 100644 (file)
@@ -364,6 +364,10 @@ bool LMDBBackend::startTransaction(const DNSName &domain, int domain_id)
 bool LMDBBackend::commitTransaction()
 {
   // cout<<"Commit transaction" <<endl;
+  if (!d_rwtxn) {
+    throw DBException("Attempt to commit a transaction while there isn't one open");
+  }
+
   d_rwtxn->txn->commit();
   d_rwtxn.reset();
   return true;
@@ -372,6 +376,10 @@ bool LMDBBackend::commitTransaction()
 bool LMDBBackend::abortTransaction()
 {
   // cout<<"Abort transaction"<<endl;
+  if (!d_rwtxn) {
+      throw DBException("Attempt to abort a transaction while there isn't one open");
+  }
+
   d_rwtxn->txn->abort();
   d_rwtxn.reset();