Fix static analysis issues 82/213882/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5 tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20191031.025243 accepted/tizen/5.5/unified/mobile/hotfix/20201027.065829 accepted/tizen/5.5/unified/wearable/hotfix/20201027.121711 accepted/tizen/unified/20190918.010317 submit/tizen/20190917.094250 submit/tizen_5.5/20191031.000003 submit/tizen_5.5_mobile_hotfix/20201026.185102 submit/tizen_5.5_wearable_hotfix/20201026.184302 tizen_5.5.m2_release
authorDaehyeon Jung <darrenh.jung@samsung.com>
Mon, 16 Sep 2019 07:02:40 +0000 (16:02 +0900)
committerDaehyeon Jung <darrenh.jung@samsung.com>
Mon, 16 Sep 2019 07:02:40 +0000 (16:02 +0900)
Change-Id: I3cacd5405bfb6fd745d7ddf343964da10e5ae865

src/common/appcontrol_manager.cc
src/common/mdg_manager.cc
src/unit_tests/dbus_service_test.cc

index 874c0aaaf7cef171e53aa328ce0a3e3686c56554..d2dd1940b25c6388c8a76209978a7d19ea1b15ea 100644 (file)
@@ -64,6 +64,7 @@ void AppControlManager::LocalReplyCb(bundle* b, int request_code,
   gint msg_id = GPOINTER_TO_INT(data);
 
   DBusService::SendAppControlReply(msg_id, raw, len);
+  free(raw);
 }
 
 int AppControlManager::LaunchLocalApplication(const unsigned char* bundle_data,
index 79a90a4734e27fc65e9027cc491e5972bb1a4ba3..16d06b0c01b0f13d35a101d939199c0827303155 100644 (file)
@@ -225,6 +225,7 @@ void MDGManager::ReceiveDataCb(int result, char* device_id, char* channel_id,
     if (!AppControlManager::GetAppControlManager().CheckAppControl(
         device_id, mdgmgr->capmgr_, data, datasize)) {
       LOG(ERROR) << "The appcontrol is not valid";
+      delete info;
       return;
     }
 
@@ -327,7 +328,7 @@ bool MDGManager::GroupForeachCb(mdg_device_h device, void* user_data) {
     return true;
   }
 
-  char* device_id;
+  char* device_id = nullptr;
   int ret = mdg_device_info_get_device_id(device, &device_id);
   if (ret != MDG_ERROR_NONE) {
     LOG(ERROR) << "Failed to get device id: " << MDGErrorToString(ret);
@@ -337,6 +338,7 @@ bool MDGManager::GroupForeachCb(mdg_device_h device, void* user_data) {
   std::vector<RemotePackageInfo> infos = mdgmgr->pm_->LoadLocalPackages();
   if (infos.empty()) {
     LOG(ERROR) << "Failed to load package list!";
+    free(device_id);
     return true;
   }
 
@@ -346,7 +348,7 @@ bool MDGManager::GroupForeachCb(mdg_device_h device, void* user_data) {
   mdgmgr->SendData(device_id, Command::ADD_PACKAGEINFO, packages_data,
       packages.size());
   delete[] packages_data;
-
+  free(device_id);
   return true;
 }
 
@@ -477,6 +479,11 @@ bool MDGManager::AddLocalDevice() {
   pm_->StoreRemotePackages("localhost", infos);
 
   LOG(ERROR) << "Add local device done";
+
+  free(device_name);
+  free(model_name);
+  free(platform_ver);
+  free(profile);
   return true;
 }
 
index 7c8875a548681f4bce76a0886148681096e876d5..aed129cbfc61caea3ffcd0b6f082639e94d2cf0d 100644 (file)
@@ -105,7 +105,8 @@ void __bundle_to_gvar_arr(bundle* b, GVariantBuilder** arr, guint* arr_len) {
 void __gvar_arr_to_cstr(GVariantIter* gvar_iter, guint len, char** str) {\r
   guchar* arr = reinterpret_cast<guchar*>(g_try_malloc(len));\r
   for (unsigned int i = 0; i < len; i++) {\r
-    g_variant_iter_loop(gvar_iter, "y", &arr[i]);\r
+    if (!g_variant_iter_loop(gvar_iter, "y", &arr[i]))\r
+      break;\r
   }\r
 \r
   *str = reinterpret_cast<char*>(arr);\r
@@ -159,9 +160,10 @@ TEST_F(DBusServiceTest, SendAppControlTest) {
   __gvar_arr_to_cstr(reply_iter, reply_len, &reply_str);\r
   g_variant_iter_free(reply_iter);\r
 \r
-  ASSERT_EQ(g_strcmp0(reply_str, test_str), 0);\r
+  int ret = g_strcmp0(reply_str, test_str);\r
   g_free(reply_str);\r
   free(val);\r
+  ASSERT_EQ(ret, 0);\r
 }\r
 \r
 int __fake_creds_gdbus_get_client(GDBusConnection* conn,\r