Add error handling of modified tidl code 59/318459/1
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 30 Sep 2024 05:45:45 +0000 (14:45 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 30 Sep 2024 05:45:45 +0000 (14:45 +0900)
Change-Id: I4cb86d576ec126bbf0801e379462e9399af1877e
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
client/src/PkgSignal.cc

index dc28b37..83494b3 100644 (file)
@@ -309,6 +309,11 @@ PkgSignal::~PkgSignal() { Unsubscribe(); }
 
 void PkgSignal::Subscribe() {
   std::lock_guard<std::recursive_mutex> lock(mutex_);
+  if (!event_add_event_handler) {
+    _E("Function symbol(event_add_event_handler) did not initialized");
+    throw InvalidIOException();
+  }
+
   int ret = event_add_event_handler(GetEventName().c_str(), EventCb, this,
                                     &event_handler_);
   if (ret != 0) {
@@ -319,7 +324,8 @@ void PkgSignal::Subscribe() {
 void PkgSignal::Unsubscribe() {
   std::lock_guard<std::recursive_mutex> lock(mutex_);
   if (event_handler_) {
-    event_remove_event_handler(event_handler_);
+    if (event_remove_event_handler)
+      event_remove_event_handler(event_handler_);
     event_handler_ = nullptr;
   }
 }
@@ -475,6 +481,10 @@ void PkgSignal::AsyncResult(std::string signal, int targetUid,
   }
 
   std::lock_guard<std::recursive_mutex> lock(mutex_);
+  if (!event_publish_app_event) {
+    _E("Function symbol(event_publish_app_event) did not initialized");
+    throw InvalidIOException();
+  }
   int ret = event_publish_app_event(GetEventName().c_str(), b);
   if (ret != 0) {
     _E("Failed to publish event. result(%d)", ret);
@@ -513,6 +523,10 @@ void PkgSignal::AsyncResultForResource(std::string signal, int targetUid,
   }
 
   std::lock_guard<std::recursive_mutex> lock(mutex_);
+  if (!event_publish_app_event) {
+    _E("Function symbol(event_publish_app_event) did not initialized");
+    throw InvalidIOException();
+  }
   int ret = event_publish_app_event(GetEventName().c_str(), b);
   if (ret != 0) {
     _E("Failed to publish event. result(%d)", ret);
@@ -545,6 +559,10 @@ void PkgSignal::AsyncResultForPkgUpgrade(std::string signal, int progress) {
   }
 
   std::lock_guard<std::recursive_mutex> lock(mutex_);
+  if (!event_publish_app_event) {
+    _E("Function symbol(event_publish_app_event) did not initialized");
+    throw InvalidIOException();
+  }
   int ret = event_publish_app_event(GetEventName().c_str(), b);
   if (ret != 0) {
     _E("Failed to publish event. result(%d)", ret);