SEGV in case mglStack reservation reaches exactly 65536 elements
A library for scientific data visualization
Brought to you by:
abalakin
in file mathgl-8.0.1/include/mgl2/base.h, line 76-84
void reserve(size_t num)
{
num = num?num+n:n+1; // final required size
if(num>(nb<<MGL_PB))
** ^ must be >=**
{
num = 1 + (num>>MGL_PB);
for(;nb<num;nb++) dat[nb] = new T[(size_t)1<<MGL_PB];
}
}
...
T &operator[](size_t i)
{ size_t d=i>>MGL_PB; return dat[d][i-(d<<MGL_PB)]; }
SEGV when num = 65536 ; block index in the range 0-65535, new block should be allocated when index > 64535, not > 65536
operator [65536] access dat[1] which has not been allocated
Anonymous
Thank you. Fixed.