[Tizen] Fix coverity : need to call bundle_free what we created by bundle_decode 79/319279/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 14 Jan 2025 03:06:28 +0000 (12:06 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 7 Feb 2025 03:36:35 +0000 (12:36 +0900)
Change-Id: I2435bfcaa468a1e51605ebb9e38f717a212ccee4
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/system/tizen-wayland/widget-controller-tizen.cpp

index 8490e6e0b24b0b7547ca32d96c75134512da8e09..c7ee737dc016c403e77c3888a0e59db1a1a43f31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,8 +67,15 @@ void WidgetImplTizen::SetContentInfo(const std::string& contentInfo)
 {
   bundle*     contentBundle;
   bundle_raw* contentBundleRaw = reinterpret_cast<bundle_raw*>(const_cast<char*>(contentInfo.c_str()));
-  int         len              = contentInfo.length();
-  contentBundle                = bundle_decode(contentBundleRaw, len);
+  uint32_t    len              = static_cast<uint32_t>(contentInfo.length());
+
+  if(DALI_UNLIKELY(contentBundleRaw == nullptr || len == 0u))
+  {
+    print_log(DLOG_ERROR, "DALI", "error : contentInfo was empty!\n");
+    return;
+  }
+
+  contentBundle = bundle_decode(contentBundleRaw, static_cast<int>(len));
 
   using SetContentInfoFunc = void (*)(void*, bundle*);
   SetContentInfoFunc setContentInfoFuncPtr;
@@ -78,7 +85,8 @@ void WidgetImplTizen::SetContentInfo(const std::string& contentInfo)
 
   if(mHandle == nullptr)
   {
-    print_log(DLOG_ERROR, "DALI", "error : %s", dlerror());
+    print_log(DLOG_ERROR, "DALI", "error : %s\n", dlerror());
+    bundle_free(contentBundle);
     return;
   }