From: Matthew Fernandez Date: Mon, 10 Oct 2022 15:13:56 +0000 (-0700) Subject: smyrna on_gvprbuttonsave_clicked: fix memory leak X-Git-Tag: 7.0.0~8^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=643f9d4a89b349263a20cc4251af6acb8f254215;p=graphviz smyrna on_gvprbuttonsave_clicked: fix memory leak 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 --- 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); }