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