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 --- binary.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'binary.cc') diff --git a/binary.cc b/binary.cc index 5f5bc1aa..0d71a11b 100644 --- a/binary.cc +++ b/binary.cc @@ -9,7 +9,7 @@ namespace ledger { const unsigned long binary_magic_number = 0xFFEED765; -static const unsigned long format_version = 0x00020018; +static const unsigned long format_version = 0x00020019; static account_t ** accounts; static account_t ** accounts_next; @@ -21,6 +21,7 @@ static unsigned int commodity_index; amount_t::bigint_t * bigints; amount_t::bigint_t * bigints_next; +unsigned int bigints_index; unsigned int bigints_count; #if DEBUG_LEVEL >= ALPHA @@ -287,11 +288,13 @@ unsigned int read_binary_journal(std::istream& in, std::size_t pool_size = (sizeof(entry_t) * count + sizeof(transaction_t) * xact_count + sizeof_bigint_t() * bigint_count); + char * item_pool = new char[pool_size]; entry_t * entry_pool = (entry_t *) item_pool; transaction_t * xact_pool = (transaction_t *) (item_pool + sizeof(entry_t) * count); + bigints_index = 0; bigints = bigints_next = (amount_t::bigint_t *) (item_pool + sizeof(entry_t) * count + sizeof(transaction_t) * xact_count); @@ -305,7 +308,7 @@ unsigned int read_binary_journal(std::istream& in, std::pair result = commodity_t::commodities.insert(commodities_pair(commodity->symbol, commodity)); - assert(result.second || master); + assert(result.second); } // Read in the entries and transactions -- cgit v1.2.3