Fix resource leak 81/174581/2 accepted/tizen/unified/20180405.064249 submit/tizen/20180405.024831
authorYunjin Lee <yunjin-.lee@samsung.com>
Tue, 3 Apr 2018 06:02:20 +0000 (15:02 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Tue, 3 Apr 2018 07:56:15 +0000 (16:56 +0900)
Change-Id: Ic13feb4e26cc5a490705ccca519eb8b8f6f37b04
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
src/privilege_info.c

index 37c31d3..a300b00 100755 (executable)
@@ -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) {