Module: check_mk
Branch: master
Commit: 79086bb27c4a5e5713c5a73d49e3f4141ddd6419
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=79086bb27c4a5e…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Wed Nov 29 14:44:53 2017 +0100
Windows agent: fix uninitialized memory errors
Fix a few uninitialized memory errors reported by Dr. Memory.
Change-Id: I1deb0a9cde90674f2ff7644fd492383e9346f5a7
---
agents/windows/sections/SectionPS.cc | 2 +-
agents/windows/sections/SectionPluginGroup.cc | 6 ------
agents/windows/sections/SectionPluginGroup.h | 22 +++++++++++-----------
3 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/agents/windows/sections/SectionPS.cc b/agents/windows/sections/SectionPS.cc
index 7c9b6ee..241cc51 100644
--- a/agents/windows/sections/SectionPS.cc
+++ b/agents/windows/sections/SectionPS.cc
@@ -231,7 +231,7 @@ bool SectionPS::outputWMI(std::ostream &out) {
bool SectionPS::outputNative(std::ostream &out) {
Debug(_logger) << "SectionPS::ouputNative";
- PROCESSENTRY32 pe32;
+ PROCESSENTRY32 pe32{0};
process_entry_t process_perfdata;
try {
diff --git a/agents/windows/sections/SectionPluginGroup.cc
b/agents/windows/sections/SectionPluginGroup.cc
index 8cbfb03..1e527aa 100644
--- a/agents/windows/sections/SectionPluginGroup.cc
+++ b/agents/windows/sections/SectionPluginGroup.cc
@@ -212,15 +212,9 @@ script_container::script_container(
, max_age(_max_age)
, timeout(_timeout)
, max_retries(_max_entries)
- , buffer_time(0)
- , buffer(nullptr)
- , buffer_work(nullptr)
, run_as_user(_user)
, type(_type)
, execution_mode(_execution_mode)
- , status(SCRIPT_IDLE)
- , last_problem(SCRIPT_NONE)
- , should_terminate(0)
, env(_env)
, logger(_logger)
, winapi(_winapi) {}
diff --git a/agents/windows/sections/SectionPluginGroup.h
b/agents/windows/sections/SectionPluginGroup.h
index 74d5e4a..1ac28b6 100644
--- a/agents/windows/sections/SectionPluginGroup.h
+++ b/agents/windows/sections/SectionPluginGroup.h
@@ -64,19 +64,19 @@ struct script_container {
const int max_age;
const int timeout;
const int max_retries;
- int retry_count;
- time_t buffer_time;
- char *buffer;
- char *buffer_work;
+ int retry_count{0};
+ time_t buffer_time{0};
+ char *buffer{nullptr};
+ char *buffer_work{nullptr};
const std::string run_as_user;
const script_type type;
const script_execution_mode execution_mode;
- script_status status;
- script_status last_problem;
- volatile bool should_terminate;
- HANDLE worker_thread;
- HANDLE job_object;
- DWORD exit_code;
+ script_status status{SCRIPT_IDLE};
+ script_status last_problem{SCRIPT_NONE};
+ volatile bool should_terminate{0};
+ HANDLE worker_thread{INVALID_HANDLE_VALUE};
+ HANDLE job_object{INVALID_HANDLE_VALUE};
+ DWORD exit_code{0};
const Environment &env;
Logger *logger;
const WinApiAdaptor &winapi;
@@ -139,7 +139,7 @@ private:
std::string _path;
script_type _type;
std::string _user;
- HANDLE _collection_thread;
+ HANDLE _collection_thread{INVALID_HANDLE_VALUE};
std::atomic<bool> _data_collection_retriggered{false};
containers_t _containers;
Configurable<script_execution_mode> _default_execution_mode;