Skip to content

Commit

Permalink
Fix a memory leak when creating a hull from 4 vertices
Browse files Browse the repository at this point in the history
Fixes leomccormack/convhull_3d/issues/leomccormack#20

There was a tiny (0 bytes, but allocating 0 bytes likely still uses memory for bookkeeping) that was also reported by Valgrind memory analyzer. This only happened when creating a hull from 4 vertices (tetrahedron). The hulls were ok and this fix doesn't affect those.
  • Loading branch information
GNSS-Stylist committed Nov 19, 2024
1 parent 0ac6fbf commit 82f27fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion convhull_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,8 @@ void convhull_3d_build_alloc
int num_pleft, cnt;
int* ind, *pleft;
ind = (int*)ch_stateful_malloc(allocator, (nVert-d-1) * sizeof(int));
pleft = (int*)ch_stateful_malloc(allocator, (nVert-d-1) * sizeof(int));
if ((nVert-d-1)!=0)
pleft = (int*)ch_stateful_malloc(allocator, (nVert-d-1) * sizeof(int));
sort_float(reldist, desReldist, ind, (nVert-d-1), 1, allocator);

/* Initialize the vector of points left. The points with the larger relative
Expand Down

0 comments on commit 82f27fb

Please sign in to comment.