Module: check_mk
Branch: master
Commit: b3cdb8bb1de08328784956c326a56ea6238ca165
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b3cdb8bb1de083…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Nov 3 14:41:25 2017 +0100
Windows agent: fix memory leaks at from_string
When string conversion failed, heap-allocated objects were not deleted.
Change-Id: I0d65731c33b5683596fc6ac57b94b3348a750766
---
agents/windows/build_version | 2 +-
agents/windows/types.cc | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 47efd9a..424f6c4 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-2994
+2996
diff --git a/agents/windows/types.cc b/agents/windows/types.cc
index 4fe4e5d..03d6219 100644
--- a/agents/windows/types.cc
+++ b/agents/windows/types.cc
@@ -88,6 +88,7 @@ mrpe_entry *from_string<mrpe_entry *>(const WinApiAdaptor
&winapi,
}
if (command_line.empty()) {
+ delete result;
throw StringConversionError(
"Invalid command specification for mrpe:\r\n"
"Format: SERVICEDESC COMMANDLINE");
@@ -96,6 +97,7 @@ mrpe_entry *from_string<mrpe_entry *>(const WinApiAdaptor
&winapi,
if (winapi.PathIsRelative(command_line.c_str())) {
Environment *env = Environment::instance();
if (env == nullptr) {
+ delete result;
throw StringConversionError("No environment");
}
snprintf(result->command_line, sizeof(result->command_line),
"%s\\%s",
@@ -146,6 +148,7 @@ winperf_counter *from_string<winperf_counter *>(const
WinApiAdaptor &winapi,
result->id =
PerfCounterObject::resolve_counter_name(winapi, base_id.c_str());
if (result->id == -1) {
+ delete result;
throw StringConversionError(
"No matching performance counter id found for " + value);
}