Menu

#252 Unrepresentable size of matrices let program crash

release_4.3.x
open
nobody
None
5
2016-12-16
2016-12-16
No

When memory is allocated in itpp/itpp/base/mat.h there is no check for datasize to be nonegative. This can cause libcto 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.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.