diff options
author | John Wiegley <johnw@newartisans.com> | 2004-07-29 01:56:53 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-07-29 01:56:53 -0400 |
commit | a2f805ef73010de7f136eba5682a909cdae3e09b (patch) | |
tree | 8db89762249e833a3c43d48a70bf7d8a3f802c87 /binary.cc | |
parent | c598550d50b23f80b3481e831d5a3261b0800e79 (diff) | |
download | fork-ledger-a2f805ef73010de7f136eba5682a909cdae3e09b.tar.gz fork-ledger-a2f805ef73010de7f136eba5682a909cdae3e09b.tar.bz2 fork-ledger-a2f805ef73010de7f136eba5682a909cdae3e09b.zip |
Exit if parsing errors are encountered
Diffstat (limited to 'binary.cc')
-rw-r--r-- | binary.cc | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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); |