From 1099d4858aa48af777da6a283985f07c48323791 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 8 Oct 2018 09:46:58 +0000 Subject: [PATCH] goto-analyzer --simplify must write files in binary mode Running goto-analyzer --simplify on Windows produced invalid goto binaries, because writing 0xa was turned into 0xd0xa (CRLF). Any goto binary with >= 10 ireps would fail in this way. The CI'ed regression tests do not catch this as we do not further process the resulting goto binaries. --- src/goto-analyzer/goto_analyzer_parse_options.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index 2108bccc248..3d06f3d7c78 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -51,6 +51,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include #include #include #include @@ -197,6 +198,10 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options) } else if(cmdline.isset("simplify")) { + if(cmdline.get_value("simplify") == "-") + throw invalid_command_line_argument_exceptiont( + "cannot output goto binary to stdout", "--simplify"); + options.set_option("simplify", true); options.set_option("outfile", cmdline.get_value("simplify")); options.set_option("general-analysis", true); @@ -634,6 +639,9 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options) } else if(options.get_bool_option("simplify")) { + PRECONDITION(!outfile.empty() && outfile != "-"); + output_stream.close(); + output_stream.open(outfile, std::ios::binary); result = static_simplifier(goto_model, *analyzer, options,