From dc8ac600b50e35d89b60caf96feb1c10bb92219b Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Fri, 14 Feb 2020 11:32:54 +0900 Subject: [PATCH] Fix Listen Method (#1410) To avoid throwing an exception in the callback function, this patch adds an exception handling about Creating Bundle(). Signed-off-by: Hwankyu Jhun --- .../Tizen.Applications.Messages/MessagePort.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs index 8b72e57..f7cddc0 100755 --- a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs +++ b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs @@ -33,6 +33,7 @@ namespace Tizen.Applications.Messages { private static readonly object s_lock = new object(); private static readonly HashSet s_portMap = new HashSet(); + private static string LogTag = "MessagePort"; // The name of the local message port private readonly string _portName = null; @@ -156,10 +157,22 @@ namespace Tizen.Applications.Messages } _messageCallBack = (int localPortId, string remoteAppId, string remotePortName, bool trusted, IntPtr message, IntPtr userData) => { - MessageReceivedEventArgs args = new MessageReceivedEventArgs() + MessageReceivedEventArgs args = new MessageReceivedEventArgs(); + try { - Message = new Bundle(new SafeBundleHandle(message, false)) - }; + args.Message = new Bundle(new SafeBundleHandle(message, false)); + } + catch (Exception ex) + { + Log.Error(LogTag, "Exception(" + ex.ToString() + ")"); + args.Message = null; + } + + if (args.Message == null) + { + Log.Error(LogTag, "Failed to create Bundle. message({0})", (message == IntPtr.Zero) ? "null" : message.ToString()); + return; + } if (!String.IsNullOrEmpty(remotePortName) && !String.IsNullOrEmpty(remoteAppId)) { -- 2.7.4