From 002d9e1925e99cec9aaca3e030456d37461ef38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Basg=C3=B6ze?= Date: Wed, 15 Apr 2020 21:17:07 +0200 Subject: [PATCH] Add error checking to C style io --- .../storage/dd/sylvan/InternalSylvanBdd.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/storm/storage/dd/sylvan/InternalSylvanBdd.cpp b/src/storm/storage/dd/sylvan/InternalSylvanBdd.cpp index e646e473d..978a05e1d 100644 --- a/src/storm/storage/dd/sylvan/InternalSylvanBdd.cpp +++ b/src/storm/storage/dd/sylvan/InternalSylvanBdd.cpp @@ -234,14 +234,24 @@ namespace storm { void InternalBdd::exportToDot(std::string const& filename, std::vector const&, bool) const { FILE* filePointer = fopen(filename.c_str() , "a+"); - this->sylvanBdd.PrintDot(filePointer); - fclose(filePointer); + // fopen returns a nullptr on failure + if (filePointer == nullptr) { + STORM_LOG_ERROR("Failure to open file: " << filename); + } else { + this->sylvanBdd.PrintDot(filePointer); + fclose(filePointer); + } } void InternalBdd::exportToText(std::string const& filename) const { FILE* filePointer = fopen(filename.c_str() , "a+"); - this->sylvanBdd.PrintText(filePointer); - fclose(filePointer); + // fopen returns a nullptr on failure + if (filePointer == nullptr) { + STORM_LOG_ERROR("Failure to open file: " << filename); + } else { + this->sylvanBdd.PrintText(filePointer); + fclose(filePointer); + } } sylvan::Bdd& InternalBdd::getSylvanBdd() {