Fix a memory leak where the result from GetGraph wasn't freed

This commit is contained in:
Ludvig Strigeus 2018-10-10 16:34:53 +02:00
parent 708f63c120
commit 121ca4c398
2 changed files with 6 additions and 3 deletions

View file

@ -805,8 +805,10 @@ void TunsafeServiceServer::HandleDisconnect() {
void TunsafeServiceServer::OnGraphAvailable() { void TunsafeServiceServer::OnGraphAvailable() {
if (want_graph_type_ != 0xffffffff) { if (want_graph_type_ != 0xffffffff) {
LinearizedGraph *graph = service_backend_->backend_->GetGraph(want_graph_type_); LinearizedGraph *graph = service_backend_->backend_->GetGraph(want_graph_type_);
if (graph) if (graph) {
connection_->WritePacket(TS_SERVICE_MSG_GRAPH, (uint8*)graph, graph->total_size); connection_->WritePacket(TS_SERVICE_MSG_GRAPH, (uint8*)graph, graph->total_size);
free(graph);
}
} }
} }

View file

@ -788,8 +788,9 @@ enum {
}; };
static void UpdateGraphReq() { static void UpdateGraphReq() {
if (g_backend && (g_current_tab != 1 || !g_ui_visible)) if (g_backend && (g_current_tab != 1 || !g_ui_visible)) {
g_backend->GetGraph(0); free(g_backend->GetGraph(-1));
}
} }
static void UpdateTabSelection() { static void UpdateTabSelection() {