summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2020-08-12 12:34:04 +0300
committerGitHub <noreply@github.com>2020-08-12 12:34:04 +0300
commit705af12fbef87b983b80223c2692996546b36c6c (patch)
tree84e4acd08893e94429a9379e7ebebcbe579ea826 /database
parent0c44ee2db972907ee96f7d7ee5ed6bdb138dda8c (diff)
Fixed global GUID map memory leak (#9725)
Fixed a memory leak on GUID object creation (when the object already exists)
Diffstat (limited to 'database')
-rw-r--r--database/engine/global_uuid_map/global_uuid_map.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/database/engine/global_uuid_map/global_uuid_map.c b/database/engine/global_uuid_map/global_uuid_map.c
index a2fedfc568..83b9b1c84e 100644
--- a/database/engine/global_uuid_map/global_uuid_map.c
+++ b/database/engine/global_uuid_map/global_uuid_map.c
@@ -240,14 +240,16 @@ int find_or_generate_guid(void *object, uuid_t *uuid, GUID_TYPE object_type, int
if (!replace_instead_of_generate) /* else take *uuid as user input */
uuid_generate(*uuid);
uv_rwlock_wrlock(&global_lock);
- int rc = guid_store_nolock(uuid, target_object, object_type);
+ rc = guid_store_nolock(uuid, target_object, object_type);
uv_rwlock_wrunlock(&global_lock);
+ if (rc)
+ freez(target_object);
return rc;
}
- //uv_rwlock_wrunlock(&global_lock);
#ifdef NETDATA_INTERNAL_CHECKS
dump_object(uuid, target_object);
#endif
+ freez(target_object);
return 0;
}