[Xcb] [PATCH libxcb] xcb_auth: Fix memory leak in _xcb_get_auth_info.
Nick Bowler
nbowler at draconx.ca
Wed Nov 10 17:49:41 PST 2010
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 at draconx.ca>
---
src/xcb_auth.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/xcb_auth.c b/src/xcb_auth.c
index 1af27fc..8cdfcc5 100644
--- a/src/xcb_auth.c
+++ b/src/xcb_auth.c
@@ -327,10 +327,14 @@ 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)
- {
- free(info->name);
- goto no_auth; /* can only authenticate sockets */
+ if (!gotsockname) {
+ 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);
--
1.7.2.2
More information about the Xcb
mailing list