star-enclosures-2d

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

commit 6c9908e30a7944cc539164f1121edb032f7afff1
parent 65b4acb25bdbab7ece3fe74812ebc97fe45b9a21
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 26 Apr 2023 10:04:09 +0200

Do not use uninitialised variables in senc2d_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/senc2d_scene.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/senc2d_scene.c b/src/senc2d_scene.c @@ -88,6 +88,9 @@ senc2d_scene_create || !(conv & (SENC2D_CONVENTION_NORMAL_INSIDE | SENC2D_CONVENTION_NORMAL_OUTSIDE))) return RES_BAD_ARG; + htable_vrtx_init(dev->allocator, &unique_vertices); + htable_seg_init(dev->allocator, &unique_segments); + scn = MEM_CALLOC(dev->allocator, 1, sizeof(struct senc2d_scene)); if(!scn) { log_err(dev, LIB_NAME":%s: could not allocate the star-enclosures-2d scene.\n", @@ -104,8 +107,6 @@ senc2d_scene_create scn->nverts = nverts; darray_segment_in_init(dev->allocator, &scn->segments_in); darray_position_init(dev->allocator, &scn->vertices); - htable_vrtx_init(dev->allocator, &unique_vertices); - htable_seg_init(dev->allocator, &unique_segments); darray_side_range_init(dev->allocator, &scn->media_use); darray_segment_enc_init(scn->dev->allocator, &scn->analyze.segments_enc);