network: Add missing freeaddrinfo on error path.
authorRyan McCabe <rmccabe@redhat.com>
Wed, 4 Dec 2019 15:33:55 +0000 (10:33 -0500)
committerRyan McCabe <rmccabe@redhat.com>
Wed, 4 Dec 2019 15:33:55 +0000 (10:33 -0500)
Add a missing freeaddrinfo on an error path to fix a memory leak
in the network code.

Changelog: network: Fix memory leak.
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
src/network.c

index a1a6e3d..613caa7 100644 (file)
@@ -2762,6 +2762,7 @@ network_config_set_bind_address(const oconfig_item_t *ci,
   *bind_address = malloc(sizeof(**bind_address));
   if (*bind_address == NULL) {
     ERROR("network plugin: network_config_set_bind_address: malloc failed.");
+    freeaddrinfo(res);
     return -1;
   }
   (*bind_address)->ss_family = res->ai_family;