Fixed global GUID map memory leak (#9725)
Fixed a memory leak on GUID object creation (when the object already exists)
Stelios Fragkakis committed
Aug 12, 2020 at 12:34 UTC
705af12fbef87b983b80223c2692996546b36c6c
1 file changed
+4
-2
database/engine/global_uuid_map/global_uuid_map.c
+4
-2
@@ -240,14 +240,16 @@ int find_or_generate_guid(void *object, uuid_t *uuid, GUID_TYPE object_type, int
240
if (!replace_instead_of_generate) /* else take *uuid as user input */
241
uuid_generate(*uuid);
242
uv_rwlock_wrlock(&global_lock);
243
- int rc = guid_store_nolock(uuid, target_object, object_type);
243
+ rc = guid_store_nolock(uuid, target_object, object_type);
244
uv_rwlock_wrunlock(&global_lock);
245
+ if (rc)
246
+ freez(target_object);
247
return rc;
248
}
247
- //uv_rwlock_wrunlock(&global_lock);
249
#ifdef NETDATA_INTERNAL_CHECKS
250
dump_object(uuid, target_object);
251
#endif
252
+ freez(target_object);
253
return 0;
254
}
255