summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8a858ae)
Bug introduced in
9dcc2aad98b9703
We can be asked to open a non-exsistent file,
in this case we should gracefully handle the
case and silently return instead of exiting.
Bug discovered and bisected down by Joona.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
fileName = fName;
ifstream::open(fileName.c_str(), ifstream::in | ifstream::binary);
fileName = fName;
ifstream::open(fileName.c_str(), ifstream::in | ifstream::binary);
- if (is_open())
- {
- // Get the book size in number of entries
- seekg(0, ios::end);
- bookSize = long(tellg()) / EntrySize;
- seekg(0, ios::beg);
+ // Silently return when asked to open a non-exsistent file
+ if (!is_open())
+ return;
+
+ // Get the book size in number of entries
+ seekg(0, ios::end);
+ bookSize = long(tellg()) / EntrySize;
+ seekg(0, ios::beg);
+ if (!good())
+ {
+ cerr << "Failed to open book file " << fileName << endl;
+ exit(EXIT_FAILURE);
- cerr << "Failed to open book file " << fileName << endl;
- exit(EXIT_FAILURE);