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>
This commit is contained in:
parent
1c4717de36
commit
5755582444
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue