From 591920a47beddb62fd829e37593e045724ec5996 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 25 Apr 2017 10:44:44 +0900 Subject: [PATCH] Fix behavior of register update info - Fix memory leak - It will return error when failed to push into queue Change-Id: I913e3c655b1182700429e263bc8fd19e9c5e8f94 Signed-off-by: Junghyun Yeon --- src/request.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/request.c b/src/request.c index f1993ca..e2ea9c6 100644 --- a/src/request.c +++ b/src/request.c @@ -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"); -- 2.7.4