summaryrefslogtreecommitdiff
path: root/balance.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-25 21:02:07 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-25 21:02:07 -0400
commitac000a67c4e9c75e11e43018e5f16242b4d99226 (patch)
treec4cf1695cfe394d35c09f7e569eee5e4de00114b /balance.h
parentab86cd8c3743ba5ae5c2ef2f7e20c51b870bb7e5 (diff)
downloadfork-ledger-ac000a67c4e9c75e11e43018e5f16242b4d99226.tar.gz
fork-ledger-ac000a67c4e9c75e11e43018e5f16242b4d99226.tar.bz2
fork-ledger-ac000a67c4e9c75e11e43018e5f16242b4d99226.zip
fixed two memory corruption bugs
Diffstat (limited to 'balance.h')
-rw-r--r--balance.h15
1 files changed, 11 insertions, 4 deletions
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