[Tizen.Log] Fix null reference exception
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 27 Jul 2023 07:19:16 +0000 (16:19 +0900)
committerChanwoo Choi <chanwoo@kernel.org>
Tue, 1 Aug 2023 10:46:25 +0000 (19:46 +0900)
When a null string comes, replace it with empty string so that not to
throw null reference exception.

Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/Tizen.Log/Tizen/Log.cs

index 74888fe..1e1c645 100755 (executable)
@@ -30,6 +30,15 @@ namespace Tizen
 
         private static unsafe void _Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
         {
+            if (tag == null)
+                tag = String.Empty;
+            if (message == null)
+                message = String.Empty;
+            if (file == null)
+                file = String.Empty;
+            if (func == null)
+                func = String.Empty;
+
             int tagByteLength = Encoding.UTF8.GetMaxByteCount(tag.Length);
             Span<byte> tagByte = tagByteLength < 1024 ? stackalloc byte[tagByteLength + 1] : new byte[tagByteLength + 1];