mirror of
https://github.com/Z3Prover/z3
synced 2025-04-13 20:38:43 +00:00
Added checks for uint parameter values in context_params
This commit is contained in:
parent
05eb78ccac
commit
6b5e49c4a1
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue