From 7c535cca845a58f0466822c5ebf8e38df19fad22 Mon Sep 17 00:00:00 2001 From: Tim Quatmann Date: Tue, 5 Nov 2019 16:26:35 +0100 Subject: [PATCH] Fixed upcasting of Exceptions in PrismParser. --- src/storm-parsers/parser/PrismParser.cpp | 4 ++++ src/storm/storage/prism/Module.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/storm-parsers/parser/PrismParser.cpp b/src/storm-parsers/parser/PrismParser.cpp index ecbb946c7..70ac58af2 100644 --- a/src/storm-parsers/parser/PrismParser.cpp +++ b/src/storm-parsers/parser/PrismParser.cpp @@ -28,6 +28,10 @@ namespace storm { try { std::string fileContent((std::istreambuf_iterator(inputFileStream)), (std::istreambuf_iterator())); result = parseFromString(fileContent, filename, prismCompatibility); + } catch(storm::exceptions::WrongFormatException& e) { + // In case of an exception properly close the file before passing exception. + storm::utility::closeFile(inputFileStream); + throw e; } catch(std::exception& e) { // In case of an exception properly close the file before passing exception. storm::utility::closeFile(inputFileStream); diff --git a/src/storm/storage/prism/Module.cpp b/src/storm/storage/prism/Module.cpp index 1c11addd2..4f141e1aa 100644 --- a/src/storm/storage/prism/Module.cpp +++ b/src/storm/storage/prism/Module.cpp @@ -6,7 +6,7 @@ namespace storm { namespace prism { - Module::Module(std::string const& moduleName, std::vector const& booleanVariables, std::vector const& integerVariables, std::vector const& clockVariables, storm::expressions::Expression const& invariant, std::vector const& commands, std::string const& filename, uint_fast64_t lineNumber) : Module(moduleName, booleanVariables, integerVariables, clockVariables, invariant, commands, "", std::map(), filename, lineNumber) { + Module::Module(std::string const& moduleName, std::vector const& booleanVariables, std::vector const& integerVariables, std::vector const& clockVariables, storm::expressions::Expression const& invariant, std::vector const& commands, std::string const& filename, uint_fast64_t lineNumber) : Module(moduleName, booleanVariables, integerVariables, clockVariables, invariant, commands, "", storm::prism::ModuleRenaming(), filename, lineNumber) { // Intentionally left empty. }