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 <youmin.ha@samsung.com>
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
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;
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
gboolean
tlm_seat_create_session (TlmSeat *seat,
- const gchar *service,
+ const gchar *service,
const gchar *username,
const gchar *password,
GHashTable *environment);