Download

ue4 std::vector<*> free memory error

I use third party libray in ue 4 called fade2d,but use below code I get error when closed method.error is strange not happen every time

{
Fade_2D dt;
Point2 p0(0.0, 0.0);
Point2 p1(1.0, 0.0);
Point2 p2(0.5, 2.0);
Point2 p3(0.5, 0.5);
dt.insert(p0);
dt.insert(p1);
dt.insert(p2);
dt.insert(p3);
std::vector<Triangle2*> vTriangles;
dt.getTrianglePointers(vTriangles); //this line remove error not happen
} //error is happen close method

[Inline Frame] std::_Deallocate(void * _Ptr, unsigned __int64 _Bytes) Line 221 C++
[Inline Frame] std::allocator<GEOM_FADE2D::Triangle2 *>::deallocate(GEOM_FADE2D::Triangle2 * * const _Count, const unsigned __int64) Line 803 C++
[Inline Frame] std::vector<GEOM_FADE2D::Triangle2 *,std::allocator<GEOM_FADE2D::Triangle2 *>>::_Tidy() Line 1695 C++
[Inline Frame] std::vector<GEOM_FADE2D::Triangle2 *,std::allocator<GEOM_FADE2D::Triangle2 *>>::{dtor}() Line 673 C++

Have you tried to pass the number of points in the Fade_2D constructor? I’m not familiar with this library, but the documentation says that



Fade_2D var;  // == Fade_2d var{3};


So, if you insert four points then it should look like



Fade_2D dt(4);