]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-host-os-info: scan-build fix
authorVictor Julien <victor@inliniac.net>
Thu, 30 Jan 2014 15:23:44 +0000 (16:23 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 31 Jan 2014 12:30:12 +0000 (13:30 +0100)
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

index 6c2b38e6cba8e9d4f2c1d200fb37f9808cbf4a40..2714d6d0b40bf0238c528d89f313b94b704630a4 100644 (file)
@@ -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;