Fix memory leak 40/132440/5
authorJiwoong Im <jiwoong.im@samsung.com>
Mon, 5 Jun 2017 07:26:44 +0000 (16:26 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Thu, 8 Jun 2017 08:02:02 +0000 (17:02 +0900)
- Fix memory leak of pkgmgrinfo handle and bundle

Change-Id: I39cc31441d7d7dde9c0a51b49101ee205bd45114
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
alarm-manager.c

index 1114c17..a96d06c 100644 (file)
@@ -513,19 +513,26 @@ static bool __check_bundle_for_update(const gchar *b_data, uid_t uid)
 {
        const char *callee_appid;
        bundle *b;
+       bool ret = false;
 
        if (strlen(b_data) == 4 && strncmp(b_data, "null", 4) == 0)
                return true;
 
        b = bundle_decode((bundle_raw *)b_data, strlen(b_data));
+       if (b == NULL)
+               return false;
+
        callee_appid = appsvc_get_appid(b);
-       if (callee_appid == NULL)
+       if (callee_appid == NULL) {
+               bundle_free(b);
                return false;
+       }
 
        if (__is_ui_app(callee_appid, uid))
-               return true;
+               ret = true;
 
-       return false;
+       bundle_free(b);
+       return ret;
 }
 
 static __alarm_info_t *__alarm_update_in_list(int uid, alarm_id_t alarm_id,
@@ -3661,7 +3668,7 @@ gboolean alarm_manager_alarm_set_global(AlarmManager *pObject, GDBusMethodInvoca
                        } else if (retval == PMINFO_R_OK && !is_global) {
                                return_code = ERR_ALARM_NOT_PERMITTED_APP;
                        }
-
+                       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
                }
                g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
        }