[Notification] Fix SVACE issue 64/253464/2
authorPawel Wasowski <p.wasowski2@samsung.com>
Wed, 10 Feb 2021 09:18:19 +0000 (10:18 +0100)
committerPawel Wasowski <p.wasowski2@samsung.com>
Wed, 10 Feb 2021 10:58:39 +0000 (10:58 +0000)
This commit fixes SVACE issue with WGID: 449860

[Verification] tct-notification-tizen-tests (auto): 100% pass rate
(The CommonNotification::SetAppControlInfoFrmJson function that was
changed, was called several times during tests)

Change-Id: If1caa5d141edb6c776a49ee9c2bfa5abc575efab

src/notification/common_notification.cc

index 1f82493716adb44f47758a4518cbf1986509f66d..dbf904dbf469103feec6158dab8e1cc38c5885e5 100644 (file)
@@ -511,6 +511,12 @@ PlatformResult CommonNotification::SetApplicationControl(app_control_h app_handl
     const std::string key = FromJson<std::string>(obj, "key");
     const picojson::array values = FromJson<picojson::array>(obj, "value");
     const char** arrayValue = (const char**)calloc(sizeof(char*), values.size());
+
+    if (!arrayValue) {
+      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Set application control error",
+                                ("Memory allocation failed"));
+    }
+
     SCOPE_EXIT {
       free(arrayValue);
     };