Fix behavior of register update info 08/126708/2
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 25 Apr 2017 01:44:44 +0000 (10:44 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 25 Apr 2017 01:51:07 +0000 (10:51 +0900)
- Fix memory leak
- It will return error when failed to push into queue

Change-Id: I913e3c655b1182700429e263bc8fd19e9c5e8f94
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/request.c

index f1993ca..e2ea9c6 100644 (file)
@@ -724,6 +724,7 @@ static int __handle_request_register_pkg_update_info(
        if (ret != PMINFO_R_OK) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               pkgmgrinfo_updateinfo_destroy(update_info);
                return -1;
        }
 
@@ -731,6 +732,7 @@ static int __handle_request_register_pkg_update_info(
        if (ret != PMINFO_R_OK) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               pkgmgrinfo_updateinfo_destroy(update_info);
                return -1;
        }
 
@@ -738,11 +740,13 @@ static int __handle_request_register_pkg_update_info(
        if (ret != PMINFO_R_OK) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               pkgmgrinfo_updateinfo_destroy(update_info);
                return -1;
        }
 
        reqkey = __generate_reqkey("register_pkg_update_info");
        if (reqkey == NULL) {
+               pkgmgrinfo_updateinfo_destroy(update_info);
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ENOMEM));
                return -1;
@@ -750,10 +754,12 @@ static int __handle_request_register_pkg_update_info(
 
        if (_push_queue(target_uid, caller_uid, reqkey,
                        REQUEST_TYPE_REGISTER_PKG_UPDATE_INFO, "default",
-                       NULL, buf, update_info))
+                       NULL, buf, update_info)) {
+               pkgmgrinfo_updateinfo_destroy(update_info);
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
-
+               return -1;
+       }
        if (!g_hash_table_insert(req_table, (gpointer)reqkey,
                                (gpointer)invocation))
                ERR("reqkey already exists");