From 0cf71befbb957f2e4919b809a4c6d709fe5b7c1c Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 30 Jan 2014 16:23:44 +0100 Subject: [PATCH] util-host-os-info: scan-build fix util-host-os-info.c:202:13: warning: Potential leak of memory pointed to by 'user_data' SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./util-debug.h:278:35: note: expanded from macro 'SCLogError' #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./util-debug.h:214:82: note: expanded from macro 'SCLogErr' char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \ ^~ 1 warning generated. --- src/util-host-os-info.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util-host-os-info.c b/src/util-host-os-info.c index 6c2b38e6cb..2714d6d0b4 100644 --- a/src/util-host-os-info.c +++ b/src/util-host-os-info.c @@ -176,6 +176,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) /* if we are here, we have an IPV4 address */ if ( (ipv4_addr = ValidateIPV4Address(ip_str)) == NULL) { SCLogError(SC_ERR_INVALID_IPV4_ADDR, "Invalid IPV4 address"); + SCHInfoFreeUserDataOSPolicy(user_data); SCFree(ip_str); return -1; } @@ -187,6 +188,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) netmask_value = atoi(netmask_str); if (netmask_value < 0 || netmask_value > 32) { SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV4 Netblock"); + SCHInfoFreeUserDataOSPolicy(user_data); SCFree(ipv4_addr); SCFree(ip_str); return -1; @@ -200,6 +202,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) /* if we are here, we have an IPV6 address */ if ( (ipv6_addr = ValidateIPV6Address(ip_str)) == NULL) { SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside"); + SCHInfoFreeUserDataOSPolicy(user_data); SCFree(ip_str); return -1; } @@ -211,6 +214,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) netmask_value = atoi(netmask_str); if (netmask_value < 0 || netmask_value > 128) { SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV6 Netblock"); + SCHInfoFreeUserDataOSPolicy(user_data); SCFree(ipv6_addr); SCFree(ip_str); return -1;