commit 2bd9dcdd439f288642ea4c9248b4d22108b2bbd5
parent 2cfa86f5719871b978b41bc70f43fd4fa64434f7
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date: Tue, 20 May 2025 09:12:13 +0200
Fix segmentation fault in function register_triangle
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/sphor_config.c b/src/sphor_config.c
@@ -184,18 +184,26 @@ register_triangle
size_t* out_id)
{
size_t* p_id = NULL;
+ size_t new_id;
struct triangle_key tri_key = TRIANGLE_KEY_NULL;
res_T res = RES_OK;
+ ASSERT(NULL != sphor);
+ ASSERT(NULL != triangle);
+ ASSERT(NULL != tri2id);
+ ASSERT(NULL != triangles);
+ ASSERT(NULL != out_id);
+
/* Reorder tri vertices to get the tri_key */
triangle_key_setup(&tri_key, triangle);
/* Get the triangle id */
p_id = htable_tri2id_find(tri2id, &tri_key);
- /* If not in the array, add it */
+ /* If not in the hash table, add it */
if (NULL == p_id) {
- *p_id = darray_triangle_size_get(triangles);
+ new_id = darray_triangle_size_get(triangles);
+ p_id = &new_id;
res = darray_triangle_push_back(triangles, triangle);
if (RES_OK != res) { goto error; }
res = darray_interface_push_back(&sphor->interfaces, &INTERFACE_NULL);