star-enclosures-3d

Extract enclosures from 3D geometry
git clone git://git.meso-star.fr/star-enclosures-3d.git
Log | Files | Refs | README | LICENSE

commit 8380bcf289e20dca8a6e0231389818f96b5f91f6
parent 0b6728c510f0da98208d661d1a8e147d8cbf1c7f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 26 Apr 2023 10:13:06 +0200

Do not use uninitialised variables in senc3d_scene_create

On exit, the temporary hash tables were released even though they might
not be initialized if the scene allocation failed. This commit corrects
this rare situation, which was indicated by a compiler warning.

Diffstat:
Msrc/senc3d_scene.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/senc3d_scene.c b/src/senc3d_scene.c @@ -87,6 +87,9 @@ senc3d_scene_create || !(conv & (SENC3D_CONVENTION_NORMAL_INSIDE | SENC3D_CONVENTION_NORMAL_OUTSIDE))) return RES_BAD_ARG; + htable_vrtx_init(dev->allocator, &unique_vertices); + htable_trg_init(dev->allocator, &unique_triangles); + scn = MEM_CALLOC(dev->allocator, 1, sizeof(struct senc3d_scene)); if(!scn) { log_err(dev, LIB_NAME":%s: could not allocate the star_enclosures-3d scene.\n", @@ -102,8 +105,6 @@ senc3d_scene_create scn->nverts = nverts; darray_triangle_in_init(dev->allocator, &scn->triangles_in); darray_position_init(dev->allocator, &scn->vertices); - htable_vrtx_init(dev->allocator, &unique_vertices); - htable_trg_init(dev->allocator, &unique_triangles); darray_side_range_init(dev->allocator, &scn->media_use); darray_triangle_enc_init(scn->dev->allocator, &scn->analyze.triangles_enc);