xcb_connect_to_display_with_auth_info: Fix memory leak
protocol and host are allocated in _xcb_parse_display but ownership of them is passed to the caller. They have to be freed in xcb_connect_to_display_with_auth_info. Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> Signed-off-by: Peter Harris <pharris@opentext.com>
This commit is contained in:
parent
18718d483e
commit
de3cdad87a
|
@ -398,24 +398,28 @@ xcb_connection_t *xcb_connect(const char *displayname, int *screenp)
|
||||||
xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname, xcb_auth_info_t *auth, int *screenp)
|
xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname, xcb_auth_info_t *auth, int *screenp)
|
||||||
{
|
{
|
||||||
int fd, display = 0;
|
int fd, display = 0;
|
||||||
char *host;
|
char *host = NULL;
|
||||||
char *protocol;
|
char *protocol = NULL;
|
||||||
xcb_auth_info_t ourauth;
|
xcb_auth_info_t ourauth;
|
||||||
xcb_connection_t *c;
|
xcb_connection_t *c;
|
||||||
|
|
||||||
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
|
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
|
||||||
|
|
||||||
if(!parsed)
|
if(!parsed) {
|
||||||
return (xcb_connection_t *) &error_connection;
|
c = (xcb_connection_t *) &error_connection;
|
||||||
else
|
goto out;
|
||||||
|
} else
|
||||||
fd = _xcb_open(host, protocol, display);
|
fd = _xcb_open(host, protocol, display);
|
||||||
free(host);
|
|
||||||
|
|
||||||
if(fd == -1)
|
if(fd == -1) {
|
||||||
return (xcb_connection_t *) &error_connection;
|
c = (xcb_connection_t *) &error_connection;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if(auth)
|
if(auth) {
|
||||||
return xcb_connect_to_fd(fd, auth);
|
c = xcb_connect_to_fd(fd, auth);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if(_xcb_get_auth_info(fd, &ourauth, display))
|
if(_xcb_get_auth_info(fd, &ourauth, display))
|
||||||
{
|
{
|
||||||
|
@ -426,5 +430,8 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
|
||||||
else
|
else
|
||||||
c = xcb_connect_to_fd(fd, 0);
|
c = xcb_connect_to_fd(fd, 0);
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(host);
|
||||||
|
free(protocol);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue