star-cad

Geometric operators for computer-aided design
git clone git://git.meso-star.fr/star-cad.git
Log | Files | Refs | README | LICENSE

commit e5db7d2fcc204f62e1d38a541d157cb9fa319eef
parent 8178cde86937595173923dff781a8db6702923a0
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed,  4 Jun 2025 11:22:01 +0200

Fix a possible invalid memory access

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

diff --git a/src/scad_geometry.c b/src/scad_geometry.c @@ -255,6 +255,7 @@ static res_T store_tags (int* dimTags, size_t count, + const int down_to_dim, struct htable_tags t[4]) { res_T res = RES_OK; @@ -265,6 +266,7 @@ store_tags int dim = dimTags[i]; int tag = dimTags[i+1]; ASSERT(dim >= 0 && dim <= 3); + if(down_to_dim > dim) continue; ERR(htable_tags_set(t+dim, &tag, &one)); } @@ -304,7 +306,8 @@ gather_tags_recursive res = RES_BAD_ARG; goto error; } - ERR(store_tags(geometries[i]->gmsh_dimTags, geometries[i]->gmsh_dimTags_n, t)); + ERR(store_tags(geometries[i]->gmsh_dimTags, geometries[i]->gmsh_dimTags_n, + down_to_dim, t)); } /* Recursively build result by dimension and list constituents, @@ -331,7 +334,7 @@ gather_tags_recursive size_t subn; gmshModelGetBoundary(dimTags[dim], sz[dim], &sub, &subn, 0, 0, 0, &ierr); ERR(gmsh_err_to_res_T(ierr)); - ERR(store_tags(sub, subn, t)); + ERR(store_tags(sub, subn, down_to_dim, t)); gmshFree(sub); sub = NULL; } ASSERT(sz[dim] == c); @@ -2847,7 +2850,7 @@ error: res_T scad_geometries_set_mesh_algorithm -(struct scad_geometry** geometries, + (struct scad_geometry** geometries, const size_t geometries_count, enum scad_mesh_algorithm algorithm) {