From 121ca4c3980eb70d5a31f88202c3955e6102d2d9 Mon Sep 17 00:00:00 2001 From: Ludvig Strigeus Date: Wed, 10 Oct 2018 16:34:53 +0200 Subject: [PATCH] Fix a memory leak where the result from GetGraph wasn't freed --- service_win32.cpp | 4 +++- tunsafe_win32.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/service_win32.cpp b/service_win32.cpp index b4e3c1f..93f8a8f 100644 --- a/service_win32.cpp +++ b/service_win32.cpp @@ -805,8 +805,10 @@ void TunsafeServiceServer::HandleDisconnect() { void TunsafeServiceServer::OnGraphAvailable() { if (want_graph_type_ != 0xffffffff) { LinearizedGraph *graph = service_backend_->backend_->GetGraph(want_graph_type_); - if (graph) + if (graph) { connection_->WritePacket(TS_SERVICE_MSG_GRAPH, (uint8*)graph, graph->total_size); + free(graph); + } } } diff --git a/tunsafe_win32.cpp b/tunsafe_win32.cpp index daea673..f786043 100644 --- a/tunsafe_win32.cpp +++ b/tunsafe_win32.cpp @@ -788,8 +788,9 @@ enum { }; static void UpdateGraphReq() { - if (g_backend && (g_current_tab != 1 || !g_ui_visible)) - g_backend->GetGraph(0); + if (g_backend && (g_current_tab != 1 || !g_ui_visible)) { + free(g_backend->GetGraph(-1)); + } } static void UpdateTabSelection() {