star-line

Structure for accelerating line importance sampling
git clone git://git.meso-star.fr/star-line.git
Log | Files | Refs | README | LICENSE

commit 7944989505339864ca222f218ffb2c1e07cffab3
parent 4a690c54da17f66fa7712bac502df49f06674a4e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 15 Apr 2026 12:07:30 +0200

Fix for a potentially invalid memory access

After resizing a dynamic array, a pointer to its buffer that was
obtained before the resizing was still being used. Depending on the
dynamic array's allocation policy (about which no assumptions can be
made), this could result in an invalid memory access, as the memory
buffer may have been updated.

Diffstat:
Msrc/sln_tree_build.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/sln_tree_build.c b/src/sln_tree_build.c @@ -210,9 +210,6 @@ merge_child_polylines vertices_range, (float)tree->args.mesh_decimation_err, tree->args.mesh_type); if(res != RES_OK) goto error; - /* Shrink the size of the vertices */ - darray_vertex_resize(&tree->vertices, vertices_range[1] + 1); - /* Setup the node polyline */ NODE(inode)->ivertex = vertices_range[0]; NODE(inode)->nvertices = ui64_to_ui32(vertices_range[1] - vertices_range[0] + 1); @@ -232,6 +229,9 @@ merge_child_polylines } } + /* Shrink the size of the vertices */ + darray_vertex_resize(&tree->vertices, vertices_range[1] + 1); + #undef NODE exit: