Fix for defects detected by static analysis in Resource Broker/Cache/Hosting.
authorjyong2.kim <jyong2.kim@samsung.com>
Wed, 24 Feb 2016 05:24:04 +0000 (14:24 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 25 Feb 2016 02:24:09 +0000 (02:24 +0000)
fix memory leak.
define copy constructor.
catch exception at destructor.

Change-Id: I52ed517449603b58f0fc04619e02757e67abf55d
Signed-off-by: jyong2.kim <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5163
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-encapsulation/src/resourceBroker/include/DevicePresence.h
service/resource-encapsulation/src/resourceBroker/src/DevicePresence.cpp
service/resource-encapsulation/src/resourceBroker/src/ResourceBroker.cpp
service/resource-encapsulation/src/resourceCache/include/DataCache.h

index cfb7bc9..c34f876 100644 (file)
@@ -42,6 +42,12 @@ namespace OIC
             DevicePresence();
             ~DevicePresence();
 
+            DevicePresence(DevicePresence &&) = delete;
+            DevicePresence(const DevicePresence &) = delete;
+
+            DevicePresence & operator = (DevicePresence &&) = delete;
+            DevicePresence & operator = (const DevicePresence &) = delete;
+
             void initializeDevicePresence(PrimitiveResourcePtr pResource);
 
             void addPresenceResource(ResourcePresence * rPresence);
index 33baf31..8d7391d 100644 (file)
@@ -42,7 +42,13 @@ namespace OIC
             if(presenceSubscriber.isSubscribing())
             {
                 OIC_LOG_V(DEBUG,BROKER_TAG,"unsubscribed presence.");
-                presenceSubscriber.unsubscribe();
+                try
+                {
+                    presenceSubscriber.unsubscribe();
+                } catch (std::exception & e)
+                {
+                    OIC_LOG_V(DEBUG,BROKER_TAG,"unsubscribed presence : %s", e.what());
+                }
             }
             resourcePresenceList.clear();
             OIC_LOG_V(DEBUG,BROKER_TAG,"destroy Timer.");
index 559b932..79f9e9d 100644 (file)
@@ -44,7 +44,6 @@ namespace OIC
             {
                 OIC_LOG_V(DEBUG, BROKER_TAG, "clear the brokerIDMap.");
                 s_brokerIDMap->erase(s_brokerIDMap->begin(), s_brokerIDMap->end());
-                s_brokerIDMap->clear();
             }
         }
 
index 090ef8a..025aca6 100644 (file)
@@ -43,6 +43,11 @@ namespace OIC
                 DataCache();
                 ~DataCache();
 
+                DataCache(const DataCache &) = default;
+                DataCache(DataCache &&) = default;
+                DataCache & operator = (const DataCache &) = default;
+                DataCache & operator = (DataCache &&) = default;
+
                 void initializeDataCache(PrimitiveResourcePtr pResource);
 
                 CacheID addSubscriber(CacheCB func, REPORT_FREQUENCY rf, long repeatTime);