d2d-conv-manager: fix svace issues 55/114155/1
authorHongkuk, Son <hongkuk.son@samsung.com>
Wed, 8 Feb 2017 10:21:26 +0000 (19:21 +0900)
committerHongkuk Son <hongkuk.son@samsung.com>
Fri, 10 Feb 2017 07:35:06 +0000 (23:35 -0800)
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: Ia238756eb4707fe8481967a6ff36022cd2e047d4

18 files changed:
daemon/ClientInfo.h
daemon/Json.h [changed mode: 0644->0755]
daemon/Request.h [changed mode: 0644->0755]
daemon/discovery_provider/SmartviewDiscoveryProvider.cpp
daemon/discovery_provider/SmartviewDiscoveryProvider.h
daemon/discovery_provider/iotcon/ServiceAdapter.h [changed mode: 0644->0755]
daemon/discovery_provider/smartview/SmartViewService.h
msf_tizen_client/include/Application.h [changed mode: 0644->0755]
msf_tizen_client/include/Channel.h
msf_tizen_client/include/Error.h [changed mode: 0644->0755]
msf_tizen_client/include/MSFDSearchProvider.h [changed mode: 0644->0755]
msf_tizen_client/include/Result.h [changed mode: 0644->0755]
msf_tizen_client/include/SearchProvider.h [changed mode: 0644->0755]
msf_tizen_client/include/Service.h
msf_tizen_client/include/mDNSSearchProvider.h [changed mode: 0644->0755]
msf_tizen_client/src/Application.cpp
msf_tizen_client/src/MSFDSearchProvider.cpp
msf_tizen_client/src/Service.cpp

index 12aea20..5e05ddb 100755 (executable)
@@ -48,7 +48,7 @@ namespace conv {
 
                protected:
                        std::string id;
-                       GDBusMethodInvocation *invocation;
+                       GDBusMethodInvocation *invocation = NULL;
        };
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 2ef2d6d..d7b8ff8
@@ -35,7 +35,7 @@ namespace conv {
        class Json {
        private:
                typedef struct _JsonNode json_node_t;
-               json_node_t *json_node;
+               json_node_t *json_node = NULL;
 
                void parse(const char* s);
                void release();
old mode 100644 (file)
new mode 100755 (executable)
index 0072310..599c1ab
@@ -63,14 +63,14 @@ namespace conv {
                        std::string __client;
                        std::string __subject;
                        Json __description;
-                       Credentials *__creds;
+                       Credentials *__creds = NULL;
                        std::string __sender;
-                       GDBusMethodInvocation *__invocation;
+                       GDBusMethodInvocation *__invocation = NULL;
 
-                       IServiceInfo* __serviceInfo;
-                       ICommunicationInfo* __communicationInfo;
-                       int __binaryLength;
-                       const unsigned char* __binary;
+                       IServiceInfo* __serviceInfo = NULL;
+                       ICommunicationInfo* __communicationInfo = NULL;
+                       int __binaryLength = 0;
+                       const unsigned char* __binary = NULL;
        };
 }
 
index 23c869b..394081a 100755 (executable)
@@ -227,6 +227,9 @@ int conv::SmartviewDiscoveryProvider::notifyDiscovered(Service* service, bool bD
        IF_FAIL_RETURN_TAG((conv_device != NULL), CONV_ERROR_INVALID_PARAMETER, _E, "failed to convert into flow device..");
 
        conv::SmartViewService* conv_service = convertIntoConvService(service);
+       if (conv_service == NULL) {
+               delete conv_device;
+       }
        IF_FAIL_RETURN_TAG((conv_service != NULL), CONV_ERROR_INVALID_PARAMETER, _E, "failed to convert into flow service..");
        conv_device->addService(conv_service);
 
@@ -246,6 +249,13 @@ int conv::SmartviewDiscoveryProvider::notifyDiscovered(Service* service, bool bD
                //2. notify
                __discoveryManager->notifyLostDevice(conv_device);
 
+               if (conv_device != NULL) {
+                       delete conv_device;
+               }
+               if (conv_service != NULL) {
+                       delete conv_service;
+               }
+
                return CONV_ERROR_NONE;
        } else {
                // Double check if the noticed one already got delivered
@@ -258,5 +268,12 @@ int conv::SmartviewDiscoveryProvider::notifyDiscovered(Service* service, bool bD
                }
        }
 
+       if (conv_device != NULL) {
+               delete conv_device;
+       }
+       if (conv_service != NULL) {
+               delete conv_service;
+       }
+
        return CONV_ERROR_NONE;
 }
index 0e1c8c8..4ea220e 100755 (executable)
@@ -45,7 +45,7 @@ namespace conv {
                        int notifyDiscovered(Service *service, bool bDiscovered);
                private:
                        //Service service;
-                       Search* search;
+                       Search* search = NULL;
 
                        map <string, conv::SmartViewService*> cache; // for double check
 
old mode 100644 (file)
new mode 100755 (executable)
index 8f835c2..111d076
@@ -41,7 +41,7 @@ namespace conv {
                private:
                        ResourceHandle  m_resource_h;
 
-                       int service_type;
+                       int service_type = 0;
                        string __serviceInfo;
        };
 
index 7e5f4b6..8892030 100755 (executable)
@@ -52,9 +52,9 @@ namespace conv
                        void printInfo();
 
                protected:
-                       int connection_state;
+                       int connection_state = 0;
                        string service_name;
-                       int service_type;
+                       int service_type = 0;
                        string __serviceInfo;
 
                        string service_version;
old mode 100644 (file)
new mode 100755 (executable)
index 766417d..fa46cb0
@@ -69,7 +69,7 @@ public:
        Application(Service *service, string uri, string id);
        Application(Service *service, string uri, string id, map<string, string> startArgs);
        virtual ~Application();
-       Result_Base *result ;
+       Result_Base *result = NULL;
        bool isConnected();
        bool isWebapp();
        void createdata_process(string data);
index d3def87..fbc527f 100755 (executable)
@@ -219,12 +219,12 @@ protected:
        string getUID();
 
        string ChannelID;
-       bool connected;
-       bool waitForOnReady;
-       Service *service;
+       bool connected = NULL;
+       bool waitForOnReady = NULL;
+       Service *service = NULL;
        string m_uri;
-       int errstatus;
-       int errcode;
+       int errstatus = 0;
+       int errcode = 0;
        string errMsg;
        OnErrorListener *onErrorListener = NULL;
        OnConnectListener *onConnectListener = NULL;
@@ -282,7 +282,7 @@ private:
 
        static pthread_t connect_thread;
        int mirror_lifetime;
-       int force_exit;
+       int force_exit = 0;
        unsigned char *cl_data;
        int cl_data_size;
        bool disconnecting;
@@ -290,12 +290,12 @@ private:
        int cl_payload_size;
        bool is_header_parsed;
        Client client;
-       long long clientconnectTime;
+       long long clientconnectTime = 0;
        bool clientisHost;
        string clientid;
        map<string, string> clientattributes;
        JsonObject *resultobj;
-       bool errobj;
+       bool errobj = NULL;
        string data;
        string method;
        string eventType;
@@ -309,14 +309,14 @@ private:
        string msg_subject;
        _message_receive_cb message_receive_cb = NULL;
        OnMessageListener *everyMessageListener = NULL;
-       int msg_id;
+       int msg_id = 0;
        bool isLaunched;
        map<string, pair<void *, int> > callbacks;
        map<void *, int> onReadyCallbacks;
        static map<string, int> json_keys;
        static JsonObject *root_json_object;
        string server_ip_address;
-       int server_port;
+       int server_port = 0;
        bool IsSecureSupport = false;
        bool IsSecureMode = false;
        bool isCommunicated = false;
old mode 100644 (file)
new mode 100755 (executable)
index 8e36969..38ffb3b
@@ -26,7 +26,7 @@ using namespace std;
 class Error
 {
 private:
-       long code;
+       long code = 0;
        string name;
        string message;
 
old mode 100644 (file)
new mode 100755 (executable)
index c35a8f1..a11427c
@@ -29,7 +29,7 @@ class Search;
 class MSFDSearchProvider: public SearchProvider
 {
 private:
-       bool receive;
+       bool receive = NULL;
        string state;
        string id;
        static long ttl;
old mode 100644 (file)
new mode 100755 (executable)
index 36945b0..71689f9
@@ -55,7 +55,7 @@ public:
        _bool_result_cb bool_result_cb = NULL;
        _service_result_cb service_result_cb = NULL;
        _error_result_cb error_result_cb = NULL;
-       void *user_data;
+       void *user_data = NULL;
        Result_Base();
        Result_Base(void*, void*, result_base_e);
        virtual ~Result_Base();
old mode 100644 (file)
new mode 100755 (executable)
index 9e7e15c..d000a27
@@ -51,7 +51,7 @@ public:
 class SearchProvider
 {
 private:
-       Search *searchListener;
+       Search *searchListener = NULL;
        //static list<Service> services;
 
 public:
index 4986fc7..1c74620 100755 (executable)
@@ -56,7 +56,7 @@ class Service
        string uri = "";
        typedef std::map<std::string, std::string> map_type;
        static Service local_service;
-       void *result_ptr;
+       void *result_ptr = NULL;
        bool SecureConnectionSupport = false;
 
        static bool success_get_id;
@@ -66,7 +66,7 @@ class Service
 public:
        Service();
        Service(string, string, string, string, string);
-       Result_Base *Resultdevice;
+       Result_Base *Resultdevice = NULL;
 
        position findServiceValue(string, char *);
        void getDeviceInfo(Result_Base*);
old mode 100644 (file)
new mode 100755 (executable)
index e6d767c..76b88d0
@@ -27,7 +27,7 @@ using namespace std;
 class mDNSSearchProvider : public SearchProvider
 {
 private:
-       Result_Base *service_cb;
+       Result_Base *service_cb = NULL;
 
 public:
        mDNSSearchProvider();
index a4f7152..ee1dc88 100755 (executable)
@@ -378,6 +378,10 @@ int Application::curl_application_calling(string uri)
                curl_install_data.clear();
                curl_easy_cleanup(curl);
 
+               if (headers != NULL) {
+                       curl_slist_free_all(headers);
+               }
+
                if (res != CURLE_OK) {
                        return -1;
                } else {
@@ -385,6 +389,10 @@ int Application::curl_application_calling(string uri)
                }
        }
 
+       if (headers != NULL) {
+               curl_slist_free_all(headers);
+       }
+
        return -1;
 }
 
@@ -461,6 +469,10 @@ int Application::curl_install(string uri)
                curl_global_cleanup();
        }
 
+       if (headers != NULL) {
+               curl_slist_free_all(headers);
+       }
+
        if (res != CURLE_OK) {
                return -1;
        } else {
index 6f17c20..54cb34b 100755 (executable)
@@ -53,9 +53,9 @@ class ResultMSFDServiceCallback : public Result_Base
 {
        public:
                MSFDSearchProvider* MSFDSearchProvider_pointer = NULL;
-               long ttl;
+               long ttl = 0;
                string ip_id;
-               int provider_type;
+               int provider_type = 0;
 
                ResultMSFDServiceCallback() { }
 
@@ -152,6 +152,7 @@ void MSFDSearchProvider::createMSFD()
        //dlog_print(DLOG_INFO, "MSF", "MSFD try bind socket success");
 
        /* use setsockopt() to request that the kernel join a multicast group */
+       memset(&mreq, 0, sizeof(mreq));
        mreq.imr_multiaddr.s_addr = inet_addr(MULTICAST_GROUP);
        mreq.imr_interface.s_addr = htonl(INADDR_ANY);
        if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
index 579abd0..b898d3b 100755 (executable)
@@ -292,6 +292,11 @@ int Service::curl_service_calling(string uri, long timeout, void *dev_result_ptr
 
                curl_easy_cleanup(curl);
        }
+
+       if (headers != NULL) {
+               curl_slist_free_all(headers);
+       }
+
        MSF_DBG("curl_service_calling end");
        return 0;
 }