Fix memory leak 80/240980/2
authorChanggyu Choi <changyu.choi@samsung.com>
Thu, 13 Aug 2020 10:03:10 +0000 (19:03 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Thu, 13 Aug 2020 10:10:33 +0000 (19:10 +0900)
Change-Id: Iacde7fe8fe768c39def208e017a89e619b635ab2
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/launchpad/src/launchpad.c

index 6e9864d..0c7bc85 100644 (file)
@@ -1805,11 +1805,11 @@ static int __dispatch_cmd_add_app_defined_loader(bundle *kb)
                return -EINVAL;
        }
 
-       bundle_encode(info->extra, &extra, &len);
 
        cpc = __find_slot_from_loader_name(loader_name);
        if (cpc == NULL) {
                lid = __make_loader_id();
+               bundle_encode(info->extra, &extra, &len);
                cpc = __add_slot(LAUNCHPAD_LOADER_TYPE_DYNAMIC, lid, 0,
                                loader_name, "/usr/bin/app-defined-loader", (const char *)extra,
                                METHOD_TIMEOUT | METHOD_VISIBILITY,
@@ -1823,6 +1823,8 @@ static int __dispatch_cmd_add_app_defined_loader(bundle *kb)
                                true,
                                false,
                                true);
+
+               free(extra);
                if (cpc == NULL) {
                        _E("cpc is NULL");
                        bundle_free_encoded_rawdata(&extra);
@@ -2689,6 +2691,8 @@ static void __add_slot_from_info(gpointer data, gpointer user_data)
                                info->app_exists,
                                info->is_hydra,
                                info->app_check);
+
+               free(extra);
                if (cpc == NULL)
                        return;