From: Ankur Bansal Date: Sat, 4 Jul 2015 13:08:08 +0000 (+0530) Subject: Add handling for error case in GroupManager::getActionSetfromString. X-Git-Tag: 1.2.0+RC1~1503 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f8f253940f71ba69a59a1790afd324675d4ffb7;p=platform%2Fupstream%2Fiotivity.git Add handling for error case in GroupManager::getActionSetfromString. Delete action in case something went wrong during parsing. Change-Id: I0e72db223ef21d0e89351d238532e168b2ca1177 Signed-off-by: Ankur Bansal Reviewed-on: https://gerrit.iotivity.org/gerrit/1523 Reviewed-by: Jihun Ha Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/things-manager/sdk/src/GroupManager.cpp b/service/things-manager/sdk/src/GroupManager.cpp index b36219f..4844e8a 100755 --- a/service/things-manager/sdk/src/GroupManager.cpp +++ b/service/things-manager/sdk/src/GroupManager.cpp @@ -486,6 +486,7 @@ ActionSet* GroupManager::getActionSetfromString(std::string description) char *plainPtr = NULL; char *attr = NULL, *desc = NULL; + Action *action = NULL; Capability *capa = NULL; ActionSet *actionset = new ActionSet(); @@ -540,7 +541,6 @@ ActionSet* GroupManager::getActionSetfromString(std::string description) if (desc != NULL) { - Action *action = NULL; strcpy(desc, token); token = strtok_r(desc, DESC_DELIMITER, &descPtr); @@ -554,7 +554,7 @@ ActionSet* GroupManager::getActionSetfromString(std::string description) token = strtok_r(attr, ATTR_DELIMITER, &attrPtr); while (token != NULL) { - if (strcmp(token, "uri") == 0) + if ( (action == NULL) && strcmp(token, "uri") == 0) //consider only first "uri" as uri, other as attribute. { token = strtok_r(NULL, ATTR_DELIMITER, &attrPtr); if(token == NULL) @@ -596,7 +596,10 @@ ActionSet* GroupManager::getActionSetfromString(std::string description) } if( action != NULL ) + { actionset->listOfAction.push_back(action); + action = NULL; + } else goto exit; //delete action; @@ -616,6 +619,7 @@ ActionSet* GroupManager::getActionSetfromString(std::string description) return actionset; exit: + DELETE(action); DELETE(capa) DELETE(actionset) DELETEARRAY(attr);