commit 1c670d11cbca39f4546a55fa3a0fa4eee655a01e
parent 190039c9b64654e19a148f2ca4c964f32f02e9b0
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 8 Nov 2022 11:08:45 +0100
Fix a memory leak
The same octree could be created multiple times by concurrent threads
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/rnatm.c b/src/rnatm.c
@@ -757,10 +757,14 @@ make_sure_octree_is_loaded(struct rnatm* atm, const size_t istruct)
ASSERT(atm && istruct < darray_accel_struct_size_get(&atm->accel_structs));
accel_struct = darray_accel_struct_data_get(&atm->accel_structs) + istruct;
- if(accel_struct->octree) goto exit; /* The octree is already loaded */
mutex_lock(atm->mutex);
+ if(accel_struct->octree) {
+ mutex_unlock(atm->mutex);
+ goto exit; /* The octree is already loaded */
+ }
+
/* Prepare to read the octree's data */
err = fsetpos(atm->octrees_storage, &accel_struct->fpos);
if(err != 0) {