mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
Adding overflow checks
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
fcc351eba6
commit
878905c13c
4 changed files with 30 additions and 6 deletions
|
@ -1066,11 +1066,14 @@ namespace datalog {
|
|||
|
||||
unsigned res_fact_size = res->m_fact_size;
|
||||
unsigned res_data_size = res_fact_size*t.row_count();
|
||||
if (res_fact_size != 0 && (res_data_size / res_fact_size) != t.row_count()) {
|
||||
throw default_exception("multiplication overflow");
|
||||
}
|
||||
|
||||
res->m_data.resize_data(res_data_size);
|
||||
|
||||
//here we can separate data creatin and insertion into hashmap, since we know
|
||||
//that no row will become duplicit
|
||||
//here we can separate data creating and insertion into hashmap, since we know
|
||||
//that no row will become duplicate
|
||||
|
||||
//create the data
|
||||
const char* t_ptr = t.m_data.begin();
|
||||
|
|
|
@ -275,6 +275,9 @@ namespace datalog {
|
|||
//the following two operations allow breaking of the object invariant!
|
||||
void resize_data(unsigned sz) {
|
||||
m_data_size = sz;
|
||||
if (sz + sizeof(uint64) < sz) {
|
||||
throw default_exception("overflow resizing data section for sparse table");
|
||||
}
|
||||
m_data.resize(sz + sizeof(uint64));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue