Check for dimacs nullptr on file creation+fn call
This commit is contained in:
@@ -14,6 +14,9 @@ bool ezCmdlineSAT::solver(const std::vector<int> &modelExpressions, std::vector<
|
||||
const std::string cnf_filename = Yosys::stringf("%s/problem.cnf", tempdir_name.c_str());
|
||||
const std::string sat_command = Yosys::stringf("%s %s", command.c_str(), cnf_filename.c_str());
|
||||
FILE *dimacs = fopen(cnf_filename.c_str(), "w");
|
||||
if (dimacs == nullptr) {
|
||||
Yosys::log_cmd_error("Failed to create CNF file `%s`.\n", cnf_filename.c_str());
|
||||
}
|
||||
|
||||
std::vector<int> modelIdx;
|
||||
for (auto id : modelExpressions)
|
||||
|
||||
@@ -1224,6 +1224,11 @@ ezSATvec ezSAT::vec(const std::vector<int> &vec)
|
||||
|
||||
void ezSAT::printDIMACS(FILE *f, bool verbose, const std::vector<std::vector<int>> &extraClauses) const
|
||||
{
|
||||
if (f == nullptr) {
|
||||
fprintf(stderr, "Usage error: printDIMACS() must not be called with a null FILE pointer\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (cnfConsumed) {
|
||||
fprintf(stderr, "Usage error: printDIMACS() must not be called after cnfConsumed()!\n");
|
||||
abort();
|
||||
|
||||
Reference in New Issue
Block a user