Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash when free memory #44

Open
keyeleo opened this issue Jun 11, 2019 · 0 comments
Open

crash when free memory #44

keyeleo opened this issue Jun 11, 2019 · 0 comments

Comments

@keyeleo
Copy link

keyeleo commented Jun 11, 2019

In src/mesh/mesh.isct.tpp about line 517, you use free() to free memory that allocated by "new" operator, there should be "delete[]". It crashes on MacOS. There also need some pointer check for safe. I already fixed locally, please update it like this:

diff --git a/src/mesh/mesh.isct.tpp b/src/mesh/mesh.isct.tpp
index 6c48930..6d47855 100644
--- a/src/mesh/mesh.isct.tpp
+++ b/src/mesh/mesh.isct.tpp
@@ -517,21 +517,32 @@ public:

     // clean up after triangulate...
  •        // in free
    
  •    free(in.pointlist);
    
  •    free(in.pointmarkerlist);
    
  •    free(in.segmentlist);
    
  •    free(in.segmentmarkerlist);
    
  •        // out free
    
  •    free(out.pointlist);
    
  •    //free(out.pointattributelist);
    
  •    free(out.pointmarkerlist);
    
  •    free(out.trianglelist);
    
  •    // in free
    
  •    if(in.pointlist)
    
  •        delete[] in.pointlist;
    
  •    if(in.pointmarkerlist)
    
  •        delete[] in.pointmarkerlist;
    
  •    if(in.segmentlist)
    
  •        delete[] in.segmentlist;
    
  •    if(in.segmentmarkerlist)
    
  •        delete[] in.segmentmarkerlist;
    
  •    // out free
    
  •    if(out.pointlist)
    
  •        free(out.pointlist);
    
  •    if(out.pointattributelist)
    
  •        free(out.pointattributelist);
    
  •    if(out.pointmarkerlist)
    
  •        free(out.pointmarkerlist);
    
  •    if(out.trianglelist)
    
  •        free(out.trianglelist);
       //free(out.triangleattributelist);
       //free(out.trianglearealist);
       //free(out.neighborlist);
    
  •    free(out.segmentlist);
    
  •    free(out.segmentmarkerlist);
    
  •    if(out.segmentlist)
    
  •        free(out.segmentlist);
    
  •    if(out.segmentmarkerlist)
    
  •        free(out.segmentmarkerlist);
       //free(out.edgelist);
       //free(out.edgemarkerlist);
    
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant