diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-11-30 00:00:17 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-11-30 00:00:17 +0100 |
| commit | dc7eab570cc8438beb6128475f828039787687d5 (patch) | |
| tree | ef4a78c51bc7102cdc8a57256da485b21b38715f | |
| parent | 77e7cf0b9b9572d6ec955e1865fd73e72ec7666b (diff) | |
Be a little more careful to handle exceptions from boost::filesystem::file_size
There has been a report of file_size throwing an exception and
crashing DCP-o-matic, but I haven't been able to reproduce it yet
(possibly related to there being missing content files).
| -rw-r--r-- | src/lib/file_log.cc | 6 | ||||
| -rw-r--r-- | src/wx/config_dialog.cc | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/file_log.cc b/src/lib/file_log.cc index 246641cc9..a9522bad5 100644 --- a/src/lib/file_log.cc +++ b/src/lib/file_log.cc @@ -69,7 +69,11 @@ FileLog::head_and_tail (int amount) const uintmax_t head_amount = amount; uintmax_t tail_amount = amount; - uintmax_t size = boost::filesystem::file_size (_file); + boost::system::error_code ec; + uintmax_t size = boost::filesystem::file_size (_file, ec); + if (size == static_cast<uintmax_t>(-1)) { + return ""; + } if (size < (head_amount + tail_amount)) { head_amount = size; diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 53c67d101..e0effec53 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -633,7 +633,7 @@ CertificateChainEditor::import_private_key () chain->set_key (dcp::file_to_string (p)); _set (chain); update_private_key (); - } catch (dcp::MiscError& e) { + } catch (std::exception& e) { error_dialog (this, _("Could not read certificate file."), std_to_wx(e.what())); } } |
