Fix crash issue
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 20 Apr 2023 21:59:29 +0000 (21:59 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 21 Apr 2023 04:35:43 +0000 (04:35 +0000)
When the app_info argument is nullptr, calling the enable_shared_from_this()
makes a crash issue. To prevent invalid access, this patch adds
the nullptr check before calling the enable_shared_from_this().

Change-Id: I6ec4acc979eb794c9d07b259658134ad793744a7
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/launch/launch_context.cc

index 787ea2b4bf83237d461ae1ac183bf391ff413851..99f6317bd096bd3de8b0e118c67396195c9a7118 100644 (file)
@@ -33,7 +33,10 @@ void LaunchContext::SetAllowedBackground(bool allowed_background) {
 }
 
 void LaunchContext::SetAppInfo(appinfo_h app_info) {
-  app_info_ = static_cast<AppInfo*>(app_info)->shared_from_this();
+  if (app_info == nullptr)
+    app_info_.reset();
+  else
+    app_info_ = static_cast<AppInfo*>(app_info)->shared_from_this();
 }
 
 void LaunchContext::SetAppStatus(app_status_h app_status) {