aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-05-15 18:39:04 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-05-23 13:28:17 +0200
commitfc0f005958ac2cba0d1b081733e19ef055d59636 (patch)
treedb1e5ef6c1d6cd2ddd1440bca42b401a81afb681 /util
parentfe2f74af2b153719fa545ffa7e7a33342d9c928b (diff)
sockets: Plug memory leak in socket_address_flatten()
socket_address_flatten() leaks a SocketAddress when its argument is null. Happens when opening a ChardevBackend of type 'udp' that is configured without a local address. Screwed up in commit bd269ebc due to last minute semantic conflict resolution. Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1494866344-11013-1-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-sockets.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index d8183f79d7..b39ae74fe0 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -1338,12 +1338,14 @@ char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
SocketAddress *socket_address_flatten(SocketAddressLegacy *addr_legacy)
{
- SocketAddress *addr = g_new(SocketAddress, 1);
+ SocketAddress *addr;
if (!addr_legacy) {
return NULL;
}
+ addr = g_new(SocketAddress, 1);
+
switch (addr_legacy->type) {
case SOCKET_ADDRESS_LEGACY_KIND_INET:
addr->type = SOCKET_ADDRESS_TYPE_INET;