From: Hwankyu Jhun Date: Tue, 8 Mar 2022 05:35:27 +0000 (+0900) Subject: Fix crash issue X-Git-Tag: submit/tizen/20220308.062636~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6a6581a65a38f41e87b84880671e9db66abc504;p=platform%2Fcore%2Fappfw%2Fappcore-widget.git Fix crash issue While creating tizen_base::Bundle() with the content info that is a string, the constructor throws an exception. Because, it's not an encoded bundle raw. This patch adds an encoding step and exception handlings to prevent crash issues. Change-Id: I58d7eacafde020496ed087d770cffd953b26f7e3 Signed-off-by: Hwankyu Jhun --- diff --git a/src/base/widget_base.cc b/src/base/widget_base.cc index 24f54cd..ddb2b33 100644 --- a/src/base/widget_base.cc +++ b/src/base/widget_base.cc @@ -662,6 +662,15 @@ int WidgetContext::SetContents(const tizen_base::Bundle& contents) { return WIDGET_ERROR_FAULT; } + try { + auto contents_raw = const_cast(contents).ToRaw(); + impl_->content_ = std::string( + reinterpret_cast(contents_raw.first.get())); + } catch (const std::bad_alloc& e) { + impl_->content_ = ""; + _E("Exception(%s) occurs", e.what()); + } + return WIDGET_ERROR_NONE; } @@ -756,8 +765,13 @@ void WidgetContext::OnTerminate() { reason = DestroyType::PERMANENT; } - tizen_base::Bundle content_info = impl_->content_.empty() ? - tizen_base::Bundle() : tizen_base::Bundle(impl_->content_); + tizen_base::Bundle content_info; + try { + if (!impl_->content_.empty()) + content_info = tizen_base::Bundle(impl_->content_); + } catch (const std::bad_alloc& e) { + _E("Exception(%s) occurs", e.what()); + } OnDestroy(reason, content_info);