From 4466e248552efc73939b42eeca13346a8e6a1f32 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 9 Jul 2022 08:17:44 -0700 Subject: [PATCH] smyrna: fix memory leak in 'mTestgvpr' Even when a text field is empty, calling `gtk_text_buffer_get_text` returns a dynamically allocated (empty) string that must be freed. --- cmd/smyrna/gui/menucallbacks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/smyrna/gui/menucallbacks.c b/cmd/smyrna/gui/menucallbacks.c index 1191312f4..aa806a0a7 100644 --- a/cmd/smyrna/gui/menucallbacks.c +++ b/cmd/smyrna/gui/menucallbacks.c @@ -286,8 +286,10 @@ void mTestgvpr(GtkWidget * widget, gpointer user_data) gtk_text_buffer_get_end_iter(gtkbuf, &endit); bf2 = gtk_text_buffer_get_text(gtkbuf, &startit, &endit, 0); - if (*args == '\0' && *bf2 == '\0') + if (*args == '\0' && *bf2 == '\0') { + g_free(bf2); return; + } argc = 1; if (*args != '\0') -- 2.40.0