summaryrefslogtreecommitdiff
path: root/src/xcb_auth.c
diff options
context:
space:
mode:
authorNick Bowler <nbowler@draconx.ca>2010-11-10 20:49:41 -0500
committerJulien Danjou <julien@danjou.info>2010-11-23 14:58:48 +0100
commit5755582444ad0ba79e661ab3173cc38e9e588d83 (patch)
tree02674425c8465c75b313be1b461656786e087b77 /src/xcb_auth.c
parent1c4717de367fe3bf1cf56bd8ef2bd30586bed023 (diff)
xcb_auth: Fix memory leak in _xcb_get_auth_info.
If the initial get_peer_sock_name(getpeername ...) succeeds, the pointer to allocated memory is overwritten by the later call to get_peer_sock_name(getsockname ...). Fix that up by freeing the allocated memory before overwriting the pointer. Signed-off-by: Nick Bowler <nbowler@draconx.ca> Signed-off-by: Julien Danjou <julien@danjou.info>
Diffstat (limited to 'src/xcb_auth.c')
-rw-r--r--src/xcb_auth.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/xcb_auth.c b/src/xcb_auth.c
index 1af27fc..4839b78 100644
--- a/src/xcb_auth.c
+++ b/src/xcb_auth.c
@@ -327,10 +327,15 @@ int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display)
if (!info->namelen)
goto no_auth; /* out of memory */
- if (!gotsockname && (sockname = get_peer_sock_name(getsockname, fd)) == NULL)
+ if (!gotsockname)
{
- free(info->name);
- goto no_auth; /* can only authenticate sockets */
+ free(sockname);
+
+ if ((sockname = get_peer_sock_name(getsockname, fd)) == NULL)
+ {
+ free(info->name);
+ goto no_auth; /* can only authenticate sockets */
+ }
}
ret = compute_auth(info, authptr, sockname);