[linux/vd-agent,02/11] session: free active session

Submitted by marcandre.lureau@redhat.com on March 22, 2019, 3:12 p.m.

Details

Message ID 20190322151246.17766-3-marcandre.lureau@redhat.com
State New
Headers show
Series "Clipboard improvements" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

marcandre.lureau@redhat.com March 22, 2019, 3:12 p.m.
From: Marc-André Lureau <marcandre.lureau@redhat.com>

According to sd_seat_get_active(2), you must free() the pointer.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 src/vdagentd/systemd-login.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/src/vdagentd/systemd-login.c b/src/vdagentd/systemd-login.c
index a11b66d..0b2dd0a 100644
--- a/src/vdagentd/systemd-login.c
+++ b/src/vdagentd/systemd-login.c
@@ -266,6 +266,7 @@  const char *session_info_get_active_session(struct session_info *si)
     int r;
     char *old_session = si->session;
 
+    free(si->session);
     si->session = NULL;
     r = sd_seat_get_active("seat0", &si->session, NULL);
     /* ENOENT happens when a seat is switching from one session to another */

Comments

On Fri, Mar 22, 2019 at 4:13 PM <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> According to sd_seat_get_active(2), you must free() the pointer.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  src/vdagentd/systemd-login.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/vdagentd/systemd-login.c b/src/vdagentd/systemd-login.c
> index a11b66d..0b2dd0a 100644
> --- a/src/vdagentd/systemd-login.c
> +++ b/src/vdagentd/systemd-login.c
> @@ -266,6 +266,7 @@ const char *session_info_get_active_session(struct session_info *si)
>      int r;
>      char *old_session = si->session;
>
> +    free(si->session);

The session does get freed just a couple of lines below here.

Cheers,
Jakub

>      si->session = NULL;
>      r = sd_seat_get_active("seat0", &si->session, NULL);
>      /* ENOENT happens when a seat is switching from one session to another */
> --
> 2.21.0.4.g36eb1cb9cf
>
Hi

On Sun, Mar 24, 2019 at 6:50 PM Jakub Janku <jjanku@redhat.com> wrote:
>
> On Fri, Mar 22, 2019 at 4:13 PM <marcandre.lureau@redhat.com> wrote:
> >
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > According to sd_seat_get_active(2), you must free() the pointer.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  src/vdagentd/systemd-login.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/src/vdagentd/systemd-login.c b/src/vdagentd/systemd-login.c
> > index a11b66d..0b2dd0a 100644
> > --- a/src/vdagentd/systemd-login.c
> > +++ b/src/vdagentd/systemd-login.c
> > @@ -266,6 +266,7 @@ const char *session_info_get_active_session(struct session_info *si)
> >      int r;
> >      char *old_session = si->session;
> >
> > +    free(si->session);
>
> The session does get freed just a couple of lines below here.

Right, my bad!
However, it should use free() and not g_free(). I'll update the patch.

thanks

>
> Cheers,
> Jakub
>
> >      si->session = NULL;
> >      r = sd_seat_get_active("seat0", &si->session, NULL);
> >      /* ENOENT happens when a seat is switching from one session to another */
> > --
> > 2.21.0.4.g36eb1cb9cf
> >
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel