代码拉取完成,页面将自动刷新
From 2cbce5fcb652226bf159f9cd9649f5869d76f6b7 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <[email protected]>
Date: Mon, 6 Jan 2020 18:40:33 -0700
Subject: [PATCH 07/19] libmetrics: Fix potential memory leak
From coverity scan
vhostmd-1.1/libmetrics/libmetrics.c:613:18: warning: Potential leak of memory pointed to by 'pmdef.context'
errno = ENOMEM;
Signed-off-by: Jim Fehlig <[email protected]>
---
libmetrics/libmetrics.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libmetrics/libmetrics.c b/libmetrics/libmetrics.c
index 756645c..6817df9 100644
--- a/libmetrics/libmetrics.c
+++ b/libmetrics/libmetrics.c
@@ -586,7 +586,8 @@ int get_metric(const char *metric_name, metric **mdef, metric_context context)
int ret = -1;
*mdef = NULL;
-
+ memset(&pmdef, 0, sizeof(private_metric));
+
if (mdisk == NULL) {
errno = ENODEV;
return -1;
@@ -628,6 +629,8 @@ int get_metric(const char *metric_name, metric **mdef, metric_context context)
*mdef = lmdef;
ret = 0;
}
+
+out:
if (pmdef.name)
free(pmdef.name);
if (pmdef.value)
@@ -635,7 +638,6 @@ int get_metric(const char *metric_name, metric **mdef, metric_context context)
if (pmdef.context)
free(pmdef.context);
-out:
/* unlock library data */
pthread_mutex_unlock(&libmetrics_mutex);
return ret;
--
2.32.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。