Skip to content

Commit

Permalink
Fix openmc-dev#2994, non-existent path when saving plot causes segmen…
Browse files Browse the repository at this point in the history
…tation fault
  • Loading branch information
pitkajuh committed Jun 16, 2024
1 parent b1b8a4c commit 0c4dc3c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ void Plot::set_output_path(pugi::xml_node plot_node)
} else {
filename = fmt::format("plot_{}", id());
}
const std::string dir_if_present =
filename.substr(0, filename.find_last_of("/") + 1);
if (!dir_exists(dir_if_present) and dir_if_present.size() > 0) {
fatal_error(fmt::format("Directory '{}' does not exist!", dir_if_present));
}
// add appropriate file extension to name
switch (type_) {
case PlotType::slice:
Expand Down

0 comments on commit 0c4dc3c

Please sign in to comment.