mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-08 07:40:34 +00:00
Fix in file qemu-sockets.c
1) Changed usage of malloc,free,strdup to qemu_malloc,qemu_free,qemu_strdup 2) Some coding style fixes (based on CODING_STYLE document) 3) Free struct addrinfo *res after failure of listen Signed-off-by: vibi <vibi_sreenivasan@cms.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
4e12cd946f
commit
39b6efc806
@ -175,7 +175,8 @@ int inet_listen(const char *str, char *ostr, int olen,
|
|||||||
#ifdef IPV6_V6ONLY
|
#ifdef IPV6_V6ONLY
|
||||||
if (e->ai_family == PF_INET6) {
|
if (e->ai_family == PF_INET6) {
|
||||||
/* listen on both ipv4 and ipv6 */
|
/* listen on both ipv4 and ipv6 */
|
||||||
setsockopt(slisten,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&off,sizeof(off));
|
setsockopt(slisten,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&off,
|
||||||
|
sizeof(off));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -207,6 +208,7 @@ listen:
|
|||||||
if (listen(slisten,1) != 0) {
|
if (listen(slisten,1) != 0) {
|
||||||
perror("listen");
|
perror("listen");
|
||||||
closesocket(slisten);
|
closesocket(slisten);
|
||||||
|
freeaddrinfo(res);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ostr) {
|
if (ostr) {
|
||||||
@ -329,10 +331,10 @@ int unix_listen(const char *str, char *ostr, int olen)
|
|||||||
opts = strchr(str, ',');
|
opts = strchr(str, ',');
|
||||||
if (opts) {
|
if (opts) {
|
||||||
len = opts - str;
|
len = opts - str;
|
||||||
path = malloc(len+1);
|
path = qemu_malloc(len+1);
|
||||||
snprintf(path, len+1, "%.*s", len, str);
|
snprintf(path, len+1, "%.*s", len, str);
|
||||||
} else
|
} else
|
||||||
path = strdup(str);
|
path = qemu_strdup(str);
|
||||||
|
|
||||||
memset(&un, 0, sizeof(un));
|
memset(&un, 0, sizeof(un));
|
||||||
un.sun_family = AF_UNIX;
|
un.sun_family = AF_UNIX;
|
||||||
@ -365,11 +367,11 @@ int unix_listen(const char *str, char *ostr, int olen)
|
|||||||
|
|
||||||
if (sockets_debug)
|
if (sockets_debug)
|
||||||
fprintf(stderr, "bind(unix:%s): OK\n", un.sun_path);
|
fprintf(stderr, "bind(unix:%s): OK\n", un.sun_path);
|
||||||
free(path);
|
qemu_free(path);
|
||||||
return sock;
|
return sock;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
free(path);
|
qemu_free(path);
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user