From ad0752e41f7804fd1d0e639c51e927ed4f430e09 Mon Sep 17 00:00:00 2001
From: Pieter Wuille <pieter.wuille@gmail.com>
Date: Sat, 18 Jun 2016 18:16:36 +0200
Subject: [PATCH] Stop trimming when mapTx is empty

---
 src/txmempool.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 205ffd637..18c54b08b 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -1075,7 +1075,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
 
     unsigned nTxnRemoved = 0;
     CFeeRate maxFeeRateRemoved(0);
-    while (DynamicMemoryUsage() > sizelimit) {
+    while (!mapTx.empty() && DynamicMemoryUsage() > sizelimit) {
         indexed_transaction_set::index<descendant_score>::type::iterator it = mapTx.get<descendant_score>().begin();
 
         // We set the new mempool min fee to the feerate of the removed set, plus the