Fix for Coverity defect(CID 104926)
authorhwajeong.son <hwajeong.son@samsung.com>
Mon, 1 Oct 2018 10:56:58 +0000 (19:56 +0900)
committerhwajeong.son <hwajeong.son@samsung.com>
Mon, 1 Oct 2018 10:56:58 +0000 (19:56 +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'

src/input_file.c

index a3465c16000a2c2d9ca992c1d09621c5a071c0de..9238a7730416f136f7e9a9c38d2939ac81dfd3b8 100755 (executable)
@@ -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;