3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-23 14:23:40 +00:00

fix a couple hundred deref-after-free bugs due to .c_str() on a temporary string

This commit is contained in:
Nuno Lopes 2020-07-11 20:24:45 +01:00
parent 48a9defb0d
commit 23e6adcad3
64 changed files with 248 additions and 229 deletions

View file

@ -836,7 +836,7 @@ namespace smt2 {
symbol ct_name = curr_id();
std::string r_str = "is-";
r_str += curr_id().str();
symbol r_name(r_str.c_str());
symbol r_name(r_str);
next();
TRACE("datatype_parser_bug", tout << ct_name << " " << r_name << "\n";);
ct_decls.push_back(pm().mk_pconstructor_decl(m_sort_id2param_idx.size(), ct_name, r_name, 0, nullptr));
@ -847,7 +847,7 @@ namespace smt2 {
symbol ct_name = curr_id();
std::string r_str = "is-";
r_str += curr_id().str();
symbol r_name(r_str.c_str());
symbol r_name(r_str);
next();
paccessor_decl_ref_buffer new_a_decls(pm());
parse_accessor_decls(new_a_decls);
@ -1148,7 +1148,8 @@ namespace smt2 {
else {
std::ostringstream str;
str << "unknown attribute " << id;
warning_msg("%s", str.str().c_str());
auto msg = str.str();
warning_msg("%s", msg.c_str());
next();
// just consume the
consume_sexpr();

View file

@ -58,7 +58,8 @@ struct pattern_validation_functor {
void operator()(app * n) {
func_decl * decl = to_app(n)->get_decl();
if (is_forbidden(decl)) {
warning_msg("(%d,%d): '%s' cannot be used in patterns.", m_line, m_pos, decl->get_name().str().c_str());
auto str = decl->get_name().str();
warning_msg("(%d,%d): '%s' cannot be used in patterns.", m_line, m_pos, str.c_str());
m_result = false;
}
}