Files
libvirt-cim/0004-memory-leaks.patch

58 lines
2.1 KiB
Diff
Raw Permalink Normal View History

From d07f47b783e8de1a49a744354ef9744334906fa4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@gmail.com>
Date: Tue, 5 Nov 2024 17:19:57 +0100
Subject: [PATCH 4/6] memory leaks
Other asprintf memory leaks found. Forwarded upstream.
Author: Adam Majer <amajer@suse.de>
---
src/Virt_ComputerSystem.c | 2 ++
src/Virt_SettingsDefineCapabilities.c | 6 ++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/Virt_ComputerSystem.c b/src/Virt_ComputerSystem.c
index da07f93..c6cbfd2 100644
--- a/src/Virt_ComputerSystem.c
+++ b/src/Virt_ComputerSystem.c
@@ -417,6 +417,8 @@ static int set_other_id_info(const CMPIBroker *broker,
CMPI_string);
}
+ free (model);
+
CMSetProperty(instance, "OtherIdentifyingInfo",
&id_info, CMPI_stringA);
diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c
index 85cb27a..9750217 100644
--- a/src/Virt_SettingsDefineCapabilities.c
+++ b/src/Virt_SettingsDefineCapabilities.c
@@ -1980,7 +1980,6 @@ static CMPIStatus set_input_props(const CMPIObjectPath *ref,
char *cap;
if (get_input_dev_caption(type, bus, &cap) != 1) {
- free(cap);
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_NOT_FOUND,
"Unable to build input caption");
@@ -1988,12 +1987,15 @@ static CMPIStatus set_input_props(const CMPIObjectPath *ref,
}
if (caption != NULL) {
- if (asprintf(&cap, "%s %s", caption, cap) == -1) {
+ char *old_cap = cap;
+ if (asprintf(&cap, "%s %s", caption, old_cap) == -1) {
+ free(old_cap);
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_NOT_FOUND,
"Unable to build input caption");
goto out;
}
+ free(old_cap);
}
inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_INPUT, DEVICE_RASD);
--
2.47.0