From 28462ed7c309cdc270fb31d207e645ce12d4a4c4 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Tue, 3 Apr 2018 15:02:20 +0900 Subject: [PATCH] Fix resource leak Change-Id: Ic13feb4e26cc5a490705ccca519eb8b8f6f37b04 Signed-off-by: Yunjin Lee --- src/privilege_info.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/privilege_info.c b/src/privilege_info.c index 37c31d3..a300b00 100755 --- a/src/privilege_info.c +++ b/src/privilege_info.c @@ -262,15 +262,15 @@ int privilege_info_get_privacy_privilege_status(const char *privilege, bool *sta TryReturn(smack_new_label_from_self(&smack_label) != -1, *status = true, PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] smack_new_label_from_self() failed."); cynara *cynara = NULL; - TryReturn(cynara_initialize(&cynara, NULL) == CYNARA_API_SUCCESS, *status = true; cynara = NULL, PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_initialize() failed."); + TryReturn(cynara_initialize(&cynara, NULL) == CYNARA_API_SUCCESS, *status = true; cynara = NULL; free(smack_label), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_initialize() failed."); char *session = NULL; session = cynara_session_from_pid(getpid()); - TryReturn(session != NULL, *status = true; cynara_finish(cynara), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_session_from_pid() failed"); + TryReturn(session != NULL, *status = true; cynara_finish(cynara); free(smack_label), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_session_from_pid() failed"); char uid[UIDMAXLEN]; int result = snprintf(uid, UIDMAXLEN, "%d", getuid()); - TryReturn(uid != NULL && result > 0, *status = true; free(session); cynara_finish(cynara), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] snprintf() for uid failed."); + TryReturn(uid != NULL && result > 0, *status = true; free(session); cynara_finish(cynara); free(smack_label), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] snprintf() for uid failed."); result = cynara_simple_check(cynara, smack_label, session, uid, privilege); int ret = PRVINFO_ERROR_NONE; @@ -278,6 +278,7 @@ int privilege_info_get_privacy_privilege_status(const char *privilege, bool *sta cynara_finish(cynara); LOGD("result of cynara_check(cynara %s, session, %s, %s) result = %d", smack_label, uid, privilege, result); + free(smack_label); if (result == CYNARA_API_ACCESS_DENIED) { *status = false; } else if (result == CYNARA_API_ACCESS_ALLOWED) { -- 2.7.4