From a2f805ef73010de7f136eba5682a909cdae3e09b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 29 Jul 2004 01:56:53 -0400 Subject: Exit if parsing errors are encountered --- binary.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'binary.cc') diff --git a/binary.cc b/binary.cc index 1ed7f2c5..f760b83c 100644 --- a/binary.cc +++ b/binary.cc @@ -282,8 +282,10 @@ account_t * read_binary_account(std::istream& in, account_t * master = NULL) return acct; } -unsigned int read_binary_ledger(std::istream& in, const std::string& leader, - ledger_t *& ledger, account_t * master) +unsigned int read_binary_ledger(std::istream& in, + const std::string& leader, + ledger_t * ledger, + account_t * master) { ident = 0; c_ident = 0; @@ -291,7 +293,7 @@ unsigned int read_binary_ledger(std::istream& in, const std::string& leader, unsigned long magic; in.read((char *)&magic, sizeof(magic)); if (magic != magic_number) - return NULL; + return 0; #ifdef DEBUG { @@ -304,19 +306,16 @@ unsigned int read_binary_ledger(std::istream& in, const std::string& leader, unsigned long this_ver; in.read((char *)&this_ver, sizeof(this_ver)); if (this_ver != format_version) - return NULL; + return 0; unsigned short len; in.read((char *)&len, sizeof(len)); if (! len) - return NULL; + return 0; in.read(buf, len); if (leader != buf) - return NULL; - - if (! ledger) - ledger = new ledger_t; + return 0; in.read((char *)&len, sizeof(len)); @@ -333,7 +332,7 @@ unsigned int read_binary_ledger(std::istream& in, const std::string& leader, in.read((char *)&old_mtime, sizeof(old_mtime)); stat(buf, &info); if (info.st_mtime > old_mtime) - return NULL; + return 0; } ledger->master = read_binary_account(in, master); -- cgit v1.2.3