提交 137d0165 编写于 作者: P Peter Krempa

remote: Fix memory leak on error path when deserializing bulk stats

The 'elem' variable along with the domain object would be leaked when
taking the error path.

Found by coverity.
上级 7199d2c5
...@@ -7730,7 +7730,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, ...@@ -7730,7 +7730,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
size_t i; size_t i;
remote_connect_get_all_domain_stats_args args; remote_connect_get_all_domain_stats_args args;
remote_connect_get_all_domain_stats_ret ret; remote_connect_get_all_domain_stats_ret ret;
virDomainStatsRecordPtr elem = NULL;
virDomainStatsRecordPtr *tmpret = NULL; virDomainStatsRecordPtr *tmpret = NULL;
if (ndoms) { if (ndoms) {
...@@ -7769,7 +7769,6 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, ...@@ -7769,7 +7769,6 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
goto cleanup; goto cleanup;
for (i = 0; i < ret.retStats.retStats_len; i++) { for (i = 0; i < ret.retStats.retStats_len; i++) {
virDomainStatsRecordPtr elem;
remote_domain_stats_record *rec = ret.retStats.retStats_val + i; remote_domain_stats_record *rec = ret.retStats.retStats_val + i;
if (VIR_ALLOC(elem) < 0) if (VIR_ALLOC(elem) < 0)
...@@ -7786,6 +7785,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, ...@@ -7786,6 +7785,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
goto cleanup; goto cleanup;
tmpret[i] = elem; tmpret[i] = elem;
elem = NULL;
} }
*retStats = tmpret; *retStats = tmpret;
...@@ -7793,6 +7793,10 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, ...@@ -7793,6 +7793,10 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
rv = ret.retStats.retStats_len; rv = ret.retStats.retStats_len;
cleanup: cleanup:
if (elem) {
virObjectUnref(elem->dom);
VIR_FREE(elem);
}
virDomainStatsRecordListFree(tmpret); virDomainStatsRecordListFree(tmpret);
xdr_free((xdrproc_t)xdr_remote_connect_get_all_domain_stats_ret, xdr_free((xdrproc_t)xdr_remote_connect_get_all_domain_stats_ret,
(char *) &ret); (char *) &ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册