From ac000a67c4e9c75e11e43018e5f16242b4d99226 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 25 Aug 2004 21:02:07 -0400 Subject: fixed two memory corruption bugs --- balance.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'balance.h') diff --git a/balance.h b/balance.h index 550ecb28..7f547e8d 100644 --- a/balance.h +++ b/balance.h @@ -39,19 +39,26 @@ class balance_t } balance_t(const amount_t& amt) { DEBUG_PRINT("ledger.memory.ctors", "ctor balance_t"); - *this += amt; + if (amt) + amounts.insert(amounts_pair(amt.commodity, amt)); } balance_t(const int value) { DEBUG_PRINT("ledger.memory.ctors", "ctor balance_t"); - *this += amount_t(value); + amount_t amt(value); + if (amt) + amounts.insert(amounts_pair(amt.commodity, amt)); } balance_t(const unsigned int value) { DEBUG_PRINT("ledger.memory.ctors", "ctor balance_t"); - *this += amount_t(value); + amount_t amt(value); + if (amt) + amounts.insert(amounts_pair(amt.commodity, amt)); } balance_t(const double value) { DEBUG_PRINT("ledger.memory.ctors", "ctor balance_t"); - *this += amount_t(value); + amount_t amt(value); + if (amt) + amounts.insert(amounts_pair(amt.commodity, amt)); } // destructor -- cgit v1.2.3