When memory is allocated in itpp/itpp/base/mat.h
there is no check for datasize
to be nonegative. This can cause libc
to throw a std::bad_alloc()
for cases, where datasize
is negative due to an overflow for the multiplication rows*cols
(which are of the type int
).
...
template<class Num_T> inline
void Mat<Num_T>::alloc(int rows, int cols)
{
if ((rows > 0) && (cols > 0)) {
datasize = rows * cols;
no_rows = rows;
no_cols = cols;
create_elements(data, datasize, factory);
}
...
}
I think this should be avoided with an assertion. Additionally, maybe datasize,rows
and cols
should be uint64_t
or long long int
to enable larger matrices. The limitation already appears, when one tries to generate an LDPC_Generator_Systematic
for the LDPC code in the tutorial on the website for code length 1000000.