Fix memory leak 29/177729/8
authormk5004.lee <mk5004.lee@samsung.com>
Thu, 3 May 2018 07:00:55 +0000 (16:00 +0900)
committerMyungKi Lee <mk5004.lee@samsung.com>
Fri, 4 May 2018 05:26:25 +0000 (05:26 +0000)
Change-Id: I73a08cea476709fc8ad38ff900e090f140438d13
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
parser/complication_parser_plugin.c
unittest/src/test_editables_container.cc
unittest/src/test_editor.cc
unittest/src/test_received_editable.cc
watchface-complication-provider/watchface-complication-provider.cc
watchface-editor/watchface-editor.cc

index 5f7e2a1..1b5c00e 100644 (file)
@@ -542,12 +542,9 @@ static int _remove_complication(sqlite3 *db, const char *pkgid)
                        sqlite3_finalize(stmt);
                        return -1;
                }
-               sqlite3_reset(stmt);
-               sqlite3_clear_bindings(stmt);
-       }
 
-       if (stmt)
                sqlite3_finalize(stmt);
+       }
 
        return 0;
 }
index 11c9d7b..d30d55a 100644 (file)
@@ -68,6 +68,9 @@ class EC : public ::testing::Test {
     received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
 
     container = new EditablesContainer();
+
+    delete candidate1;
+    delete candidate2;
   }
   virtual void TearDown() {
     delete received;
@@ -109,6 +112,9 @@ TEST_F(EC, AddRemove)
   ReceivedEditable* re = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
   std::shared_ptr<IEditable> ed = static_cast<std::shared_ptr<IEditable>>(re);
 
+  delete candidate1;
+  delete candidate2;
+
   EXPECT_EQ(EC::container->Add(ed, 1), 0);
   EXPECT_EQ(EC::container->Remove(ed), 0);
 }
@@ -152,4 +158,6 @@ TEST_F(EC, GetData)
 
   EXPECT_EQ(watchface_editable_get_geometry(EC::received, &geo), 0);
   EXPECT_EQ(watchface_editable_get_editable_name(EC::received, &get_editable_name), 0);
+
+  free(get_editable_name);
 }
index 6dd3d3c..f17d7dd 100644 (file)
@@ -116,6 +116,8 @@ class WEL : public ::testing::Test {
     received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
     editables = g_list_append(editables, received);
 
+    delete candidate1;
+    delete candidate2;
   }
   virtual void TearDown(){
     delete received;
index 1352c51..2dc5b0a 100644 (file)
@@ -63,6 +63,9 @@ class RE : public ::testing::Test {
 
     bundle_encode(data, &raw_data, &len);
     received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
+
+    delete candidate1;
+    delete candidate2;
   }
   virtual void TearDown() {
     delete received;
index 482e6c7..c77bafe 100644 (file)
@@ -641,8 +641,9 @@ extern "C" EXPORT_API int watchface_complication_provider_touch_launch_get_provi
       TOUCH_LAUNCH_PROVIDER_ID_KEY, &value);
   if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
     return ret;
+
   *provider_id = strdup(value);
-  if (provider_id == NULL)
+  if (*provider_id == NULL)
     return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
 
   return WATCHFACE_COMPLICATION_ERROR_NONE;
index f23dddd..8b5727c 100644 (file)
@@ -239,15 +239,16 @@ extern "C" EXPORT_API const watchface_editable_h watchface_editor_editable_list_
     return NULL;
   }
 
-  GList* iter = list;
+  GList* iter = g_list_first(list);
   int idx = 0;
   while (iter) {
     if (idx == nth)
-      break;
+      return iter->data;
     idx++;
     iter = iter->next;
   }
-  return iter->data;
+
+  return NULL;
 }
 
 extern "C" EXPORT_API int watchface_editor_editable_candidate_list_get_size(