From be736343b6afaadba39bcfd64f2b6a50a9a83858 Mon Sep 17 00:00:00 2001 From: "jjack.lee" Date: Tue, 30 Dec 2014 14:22:58 +0900 Subject: [PATCH] Fix some issues of GroupManager - subscribeCollectionPresence() - IOT-197 : Handle null parameter - IOT-198 : Check that resource has child resource. - findCandidateResources() - IOT-210 : Handle null parameter Change-Id: I6961aa776e5883890da226f07d3cfcf64571279c Signed-off-by: Jack Lee --- service/things-manager/sdk/src/GroupManager.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/service/things-manager/sdk/src/GroupManager.cpp b/service/things-manager/sdk/src/GroupManager.cpp index d3ddab4..216ac0b 100644 --- a/service/things-manager/sdk/src/GroupManager.cpp +++ b/service/things-manager/sdk/src/GroupManager.cpp @@ -197,12 +197,16 @@ OCStackResult GroupManager::findCandidateResources(std::vector< std::string > re { return OC_STACK_ERROR; } + if(callback == NULL) + { + return OC_STACK_ERROR; + } std::sort(resourceTypes.begin(), resourceTypes.end()); resourceTypes.erase(std::unique(resourceTypes.begin(), resourceTypes.end()), resourceTypes.end()); - if (waitsec != -1) + if (waitsec >= 0) { candidateRequestForTimer.insert(std::make_pair(resourceTypes, callback)); } @@ -222,7 +226,7 @@ OCStackResult GroupManager::findCandidateResources(std::vector< std::string > re std::placeholders::_1, waitsec))); } - if (waitsec != -1) + if (waitsec >= 0) { std::thread exec( std::function< void(int second) >( @@ -284,6 +288,12 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep, } */ std::vector< OCRepresentation > children = rep.getChildren(); + + if(children.size() == 0 ) + { + callback("", OC_STACK_ERROR); + return; + } for (auto oit = children.begin(); oit != children.end(); ++oit) { @@ -357,6 +367,11 @@ void GroupManager::onGetForPresence(const HeaderOptions& headerOptions, OCStackResult GroupManager::subscribeCollectionPresence( std::shared_ptr< OCResource > collectionResource, CollectionPresenceCallback callback) { + if(callback == NULL || collectionResource == NULL) + { + return OC_STACK_ERROR; + } + OCStackResult result = OC_STACK_OK; //callback("core.room",OC_STACK_OK); -- 2.7.4