Fix for Coverity defect(CID 104926) 89/166989/1 submit/tizen_4.0/20180115.023822
authornshero.lee <nshero.lee@samsung.com>
Mon, 15 Jan 2018 01:57:57 +0000 (10:57 +0900)
committernshero.lee <nshero.lee@samsung.com>
Mon, 15 Jan 2018 01:57:57 +0000 (10:57 +0900)
Due to conditional free, the defect was occured.
Change the code to free properly.
If memory is alloced, it will be freed at the end of 'if'

Change-Id: I1285128e68378ddcaa9b07005dbc09b41c0ae8bf
Signed-off-by: nshero.lee <nshero.lee@samsung.com>
src/input_file.c

index a3465c16000a2c2d9ca992c1d09621c5a071c0de..9238a7730416f136f7e9a9c38d2939ac81dfd3b8 100644 (file)
@@ -456,9 +456,6 @@ static int __parse_system_data(json_object * inputObj, sa_config_s * setupConfig
                        setupConfig->systemData->proxy = (sa_proxy_s *) malloc(sizeof(sa_proxy_s));
                        if (setupConfig->systemData->proxy != NULL) {
                                memcpy(setupConfig->systemData->proxy->httpProxyHost, httpProxyHost, MIN(strlen(httpProxyHost), sizeof(setupConfig->systemData->proxy->httpProxyHost) - 1));
-                               free(httpProxyHost);
-                               httpProxyHost = NULL;
-
                                //httpProxyPort
                                setupConfig->systemData->proxy->httpProxyPort = json_get_int_from_obj(inputObj, SA_CONFIG_NETWORKDATA_HTTPPROXYPORT);
 
@@ -470,6 +467,9 @@ static int __parse_system_data(json_object * inputObj, sa_config_s * setupConfig
                        ret = -1;
                        _D("malloc fail setupConfig->systemData");
                }
+
+               free(httpProxyHost);
+               httpProxyHost = NULL;
        }
 
        return ret;