[go: up one dir, main page]

Menu

#51 SEGV in case mglStack reservation reaches exactly 65536 elements

v1.0_(example)
closed
nobody
None
1
2025-02-27
2024-09-03
Anonymous
No

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

Discussion

  • Alexey Balakin

    Alexey Balakin - 2024-09-13

    Thank you. Fixed.

     
  • Alexey Balakin

    Alexey Balakin - 2025-02-27
    • status: open --> closed
     

Anonymous
Anonymous

Add attachments
Cancel