[notification] fix prevent CID 23603, 24335
authorHyunjin Park <hj.na.park@samsung.com>
Thu, 10 Sep 2015 11:18:35 +0000 (20:18 +0900)
committerHyunjin Park <hj.na.park@samsung.com>
Thu, 10 Sep 2015 11:30:28 +0000 (20:30 +0900)
- SCOPE_EXIT position is after return statement.
- move it before return statement.
- TCT result : 100% passed

Change-Id: I17ce78347220872d6062b4ec1f440cf0293d6f11

src/notification/notification_manager.cc
src/notification/status_notification.cc

index 9da44d4..c9c1f41 100644 (file)
@@ -98,13 +98,7 @@ PlatformResult NotificationManager::Get(const picojson::object& args,
   int id = std::stoi(FromJson<std::string>(args, "id"));
 
   app_control_h app_control = nullptr;
-  notification_h noti_handle;
-  PlatformResult status = StatusNotification::GetNotiHandle(id, &noti_handle);
-  if (status.IsError())
-  {
-    LoggerE("Failed: GetNotiHandle");
-    return status;
-  }
+  notification_h noti_handle = nullptr;
 
   SCOPE_EXIT {
     if (app_control) {
@@ -113,6 +107,13 @@ PlatformResult NotificationManager::Get(const picojson::object& args,
     free(noti_handle);
   };
 
+  PlatformResult status = StatusNotification::GetNotiHandle(id, &noti_handle);
+  if (status.IsError())
+  {
+    LoggerE("Failed: GetNotiHandle");
+    return status;
+  }
+
   status = StatusNotification::GetAppControl(noti_handle, &app_control);
   if (status.IsError())
   {
index efd69b4..73aa21e 100644 (file)
@@ -1172,8 +1172,16 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
   int id = NOTIFICATION_PRIV_ID_NONE;
   int ret;
 
-  notification_h noti_handle;
+  notification_h noti_handle = nullptr;
   app_control_h app_control = NULL;
+
+  SCOPE_EXIT {
+    if (app_control) {
+      app_control_destroy(app_control);
+    }
+    free(noti_handle);
+  };
+
   if (is_update) {
     id = std::stoi(common::FromJson<std::string>(noti_obj, "id"));
 
@@ -1187,13 +1195,6 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
       return status;
   }
 
-  SCOPE_EXIT {
-    if (app_control) {
-      app_control_destroy(app_control);
-    }
-    free(noti_handle);
-  };
-
   status = SetLayout(noti_handle, status_type);
   if (status.IsError()) {
     return status;