Skip to content

Commit

Permalink
Fix freed memory access issue: A vector may be resized during use, wh…
Browse files Browse the repository at this point in the history
…ich would invalidate all pointers into it (openscad#5270)
  • Loading branch information
kintel authored Aug 25, 2024
1 parent 392223e commit 660dd12
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/glview/cgal/CGAL_OGL_VBO_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ class VBOPolyhedron : public virtual Polyhedron
}

static inline void CGAL_GLU_TESS_CALLBACK combineCallback(GLdouble coords[3], GLvoid *[4], GLfloat [4], GLvoid **dataOut) {
static std::vector<GLdouble> vertexCache;
static std::vector<std::unique_ptr<Vector3d>> vertexCache;
if (dataOut) {
vertexCache.push_back(coords[0]);
vertexCache.push_back(coords[1]);
vertexCache.push_back(coords[2]);
*dataOut = &(vertexCache.back()) - 2;
vertexCache.push_back(std::make_unique<Vector3d>(coords));
*dataOut = vertexCache.back().get();
} else {
vertexCache.clear();
}
Expand Down

0 comments on commit 660dd12

Please sign in to comment.