From 643f9d4a89b349263a20cc4251af6acb8f254215 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Mon, 10 Oct 2022 08:13:56 -0700 Subject: [PATCH] smyrna on_gvprbuttonsave_clicked: fix memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The `gtk_text_buffer_get_text` docs¹ note: Return value … The caller of the method takes ownership of the data, and is responsible for freeing it. ¹ https://docs.gtk.org/gtk4/method.TextBuffer.get_text.html --- cmd/smyrna/gui/menucallbacks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/smyrna/gui/menucallbacks.c b/cmd/smyrna/gui/menucallbacks.c index 4e4e8b6ef..772bb63d3 100644 --- a/cmd/smyrna/gui/menucallbacks.c +++ b/cmd/smyrna/gui/menucallbacks.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "frmobjectui.h" void mAttributesSlot(GtkWidget * widget, gpointer user_data) @@ -414,6 +415,7 @@ void on_gvprbuttonsave_clicked(GtkWidget * widget, gpointer user_data) gtk_text_buffer_get_end_iter(gtkbuf, &endit); bf2 = gtk_text_buffer_get_text(gtkbuf, &startit, &endit, 0); fprintf(output_file, "%s", bf2); + free(bf2); fclose(output_file); } -- 2.40.0