3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-13 04:28:17 +00:00

Added checks for uint parameter values in context_params

This commit is contained in:
Christoph M. Wintersteiger 2015-11-14 17:25:18 +00:00
parent 05eb78ccac
commit 6b5e49c4a1
2 changed files with 29 additions and 11 deletions

View file

@ -48,7 +48,26 @@ void context_params::set_bool(bool & opt, char const * param, char const * value
}
else {
std::stringstream strm;
strm << "invalid value '" << value << "' for Boolean parameter '" << param;
strm << "invalid value '" << value << "' for Boolean parameter '" << param << "'";
throw default_exception(strm.str());
}
}
void context_params::set_uint(unsigned & opt, char const * param, char const * value) {
bool is_uint = true;
size_t sz = strlen(value);
for (unsigned i = 0; i < sz; i++) {
if (!(value[i] >= '0' && value[i] <= '9'))
is_uint = false;
}
if (is_uint) {
long val = strtol(value, 0, 10);
opt = static_cast<unsigned>(val);
}
else {
std::stringstream strm;
strm << "invalid value '" << value << "' for unsigned int parameter '" << param << "'";
throw default_exception(strm.str());
}
}
@ -63,12 +82,10 @@ void context_params::set(char const * param, char const * value) {
p[i] = '_';
}
if (p == "timeout") {
long val = strtol(value, 0, 10);
m_timeout = static_cast<unsigned>(val);
set_uint(m_timeout, param, value);
}
else if (p == "rlimit") {
long val = strtol(value, 0, 10);
m_rlimit = static_cast<unsigned>(val);
set_uint(m_rlimit, param, value);
}
else if (p == "type_check" || p == "well_sorted_check") {
set_bool(m_well_sorted_check, param, value);

View file

@ -25,6 +25,7 @@ class ast_manager;
class context_params {
void set_bool(bool & opt, char const * param, char const * value);
void set_uint(unsigned & opt, char const * param, char const * value);
public:
bool m_auto_config;