From 1ff7d912fe329867a40c8e473cf0bde8d55202ef Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 1 Jul 2016 08:13:09 -0400 Subject: [PATCH] main: fix leak in log handler --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.c b/src/main.c index 2f799e5..cc62e05 100644 --- a/src/main.c +++ b/src/main.c @@ -94,60 +94,62 @@ on_bus_acquired (GDBusConnection *connection, static void on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { g_debug ("got NameLost, exiting"); g_main_loop_quit (loop); } static gboolean debug; static void on_log_debug (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) { GString *string; const gchar *progname; int ret G_GNUC_UNUSED; string = g_string_new (NULL); progname = g_get_prgname (); g_string_append_printf (string, "(%s:%lu): %s%sDEBUG: %s\n", progname ? progname : "process", (gulong)getpid (), log_domain ? log_domain : "", log_domain ? "-" : "", message ? message : "(NULL) message"); ret = write (1, string->str, string->len); + + g_string_free (string, TRUE); } static void log_handler (const gchar *domain, GLogLevelFlags level, const gchar *message, gpointer data) { /* filter out DEBUG messages if debug isn't set */ if ((level & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_DEBUG && !debug) return; g_log_default_handler (domain, level, message, data); } static gboolean on_signal_quit (gpointer data) { g_main_loop_quit (data); return FALSE; } int main (int argc, char *argv[]) { GError *error; gint ret; GBusNameOwnerFlags flags; GOptionContext *context; static gboolean replace; -- 2.7.4