Fix Null point dereferences (Prevent) 95/164495/2
authorsaerome.kim <saerome.kim@samsung.com>
Tue, 19 Dec 2017 09:07:45 +0000 (18:07 +0900)
committersaerome kim <saerome.kim@samsung.com>
Tue, 19 Dec 2017 09:34:12 +0000 (09:34 +0000)
- CID 72904

Change-Id: Ib9a5140de2f0280577c5e444a529dda1b3db3ab6
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
src/wmesh-bridge.c

index 20481e8..7a57f12 100644 (file)
@@ -183,9 +183,9 @@ int wmesh_bridge_del_interface(const char* bridge_name, const char* interface)
        int ret = WMESHD_ERROR_NONE;
        int val = 0;
        int br_fd = 0;
+       int if_index;
 
        struct ifreq ifr;
-       int if_index = if_nametoindex(interface);
 
        char str_error[ERROR_MESSAGE_LENGTH];
 #if !defined(SIOCBRDELIF)
@@ -202,6 +202,8 @@ int wmesh_bridge_del_interface(const char* bridge_name, const char* interface)
                return WMESHD_ERROR_INVALID_PARAMETER;
        }
 
+       if_index = if_nametoindex(interface);
+
        br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
        if (br_fd < 0) {
                strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);