From c8e080b124ac640c9f5fdff831efda615c035822 Mon Sep 17 00:00:00 2001 From: Dmitry Isaikin Date: Mon, 27 Nov 2023 04:14:29 +0300 Subject: [PATCH] win-syscalls: fix memory leaks introduced in #1721 (#1747) --- src/plugins/syscalls/win.cpp | 11 +++++++++++ src/plugins/syscalls/win.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/syscalls/win.cpp b/src/plugins/syscalls/win.cpp index 8d7f08765..b4cf8668a 100644 --- a/src/plugins/syscalls/win.cpp +++ b/src/plugins/syscalls/win.cpp @@ -786,3 +786,14 @@ void win_syscalls::print_syscall( std::move(fmt_args) ); } + +win_syscalls::~win_syscalls() +{ + GSList* loop = this->strings_to_free; + while (loop) + { + g_free(loop->data); + loop = loop->next; + } + g_slist_free(this->strings_to_free); +} diff --git a/src/plugins/syscalls/win.h b/src/plugins/syscalls/win.h index 9ced4718e..1f924ee65 100644 --- a/src/plugins/syscalls/win.h +++ b/src/plugins/syscalls/win.h @@ -111,7 +111,7 @@ class win_syscalls : public syscalls_base { public: - GSList* strings_to_free; + GSList* strings_to_free = nullptr; std::array, 2> sst; @@ -139,6 +139,7 @@ class win_syscalls : public syscalls_base void print_syscall(drakvuf_t drakvuf, drakvuf_trap_info_t* info, int nr, const char* module, const syscalls_ns::syscall_t* sc, std::vector args, privilege_mode_t mode, std::optional from_dll); win_syscalls(drakvuf_t drakvuf, const syscalls_config* config, output_format_t output); + ~win_syscalls(); }; namespace syscalls_ns