resource-container: fix segmentation fault if configuration is not initialized
authorHauke Mehrtens <hauke.mehrtens@lantiq.com>
Wed, 11 Nov 2015 17:06:00 +0000 (18:06 +0100)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 24 Nov 2015 01:55:06 +0000 (01:55 +0000)
When the configuration is not initialized, for example because the
demon does not use the configuration, this program will run into a
segmentation fault when a new resource gets registered.

Change-Id: I1a6b4b468bdc74136e91ffb5c5dbc3c4d276fe15
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4151
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/resource-container/src/ResourceContainerImpl.cpp

index 9607622..542fb7a 100644 (file)
@@ -296,7 +296,7 @@ namespace OIC
                              std::string(strUri + ", " +
                                          strResourceType).c_str());
 
-                    if (m_config->isHasInput(resource->m_bundleId))
+                    if (m_config && m_config->isHasInput(resource->m_bundleId))
                     {
                         discoverInputResource(strUri);
                     }
@@ -326,7 +326,7 @@ namespace OIC
                      std::string(resource->m_uri + ", " +
                                  resource->m_resourceType).c_str());
 
-            if (m_config->isHasInput(resource->m_bundleId))
+            if (m_config && m_config->isHasInput(resource->m_bundleId))
             {
                 undiscoverInputResource(strUri);
             }