From: Youmin Ha Date: Tue, 13 Oct 2015 05:14:10 +0000 (+0900) Subject: Fix memory leak X-Git-Tag: accepted/tizen/mobile/20151013.230308~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=593f938f68abdc94c3bc71929142365e7b01e9dc;p=platform%2Fcore%2Fsystem%2Ftlm.git Fix memory leak The string got from tlm_seat_get_occupying_username() must be freed after used. This commit fixes the memory leak. Change-Id: If05dae74ad2027cd6c9bf81ce2d43e608d4982b9 Signed-off-by: Youmin Ha --- diff --git a/src/daemon/tlm-dbus-observer.c b/src/daemon/tlm-dbus-observer.c index c57f690..3569ce3 100644 --- a/src/daemon/tlm-dbus-observer.c +++ b/src/daemon/tlm-dbus-observer.c @@ -419,12 +419,14 @@ _is_valid_switch_user_dbus_request( TlmDbusRequest *dbus_request, TlmSeat *seat) { - if (0 == g_strcmp0(dbus_request->username, - tlm_seat_get_occupying_username(seat))) { + gboolean ret = TRUE; + gchar *occupying_username = tlm_seat_get_occupying_username(seat); + if (0 == g_strcmp0(dbus_request->username,occupying_username)) { WARN("Cannot switch to same username"); - return FALSE; + ret = FALSE; } - return TRUE; + g_free(occupying_username); + return ret; } static gboolean diff --git a/src/daemon/tlm-seat.c b/src/daemon/tlm-seat.c index 547954f..bbe0815 100644 --- a/src/daemon/tlm-seat.c +++ b/src/daemon/tlm-seat.c @@ -455,7 +455,7 @@ tlm_seat_get_id (TlmSeat *seat) return (const gchar*) seat->priv->id; } -const gchar * +gchar * tlm_seat_get_occupying_username (TlmSeat *seat) { TlmSeatPrivate *priv = TLM_SEAT_PRIV (seat); if (!priv->session) return NULL; diff --git a/src/daemon/tlm-seat.h b/src/daemon/tlm-seat.h index b0e0567..36ff036 100644 --- a/src/daemon/tlm-seat.h +++ b/src/daemon/tlm-seat.h @@ -68,10 +68,10 @@ const gchar * tlm_seat_get_id (TlmSeat *seat); /** Get the username who occupies the seat - * @return The name of the user who holds the seat + * @return The name of the user who holds the seat (to be freed) * @return NULL if nobody occupies the seat */ -const gchar * +gchar * tlm_seat_get_occupying_username (TlmSeat* seat); gboolean @@ -83,7 +83,7 @@ tlm_seat_switch_user (TlmSeat *seat, gboolean tlm_seat_create_session (TlmSeat *seat, - const gchar *service, + const gchar *service, const gchar *username, const gchar *password, GHashTable *environment);