From d63493f5ff2af347ba5f3c1e469807c93fbe7f4e Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 9 Mar 2023 10:46:20 +0900 Subject: [PATCH] Add missing log and pointer reset code - Issue: In some condition, the file pointer did not closed and made a memory leakage. - Solution: In previous patch, a log for checking error status was missed. So, the behavior of the code was not predictable. Thus, this patch restores the log and also adds pointer reset code in order to prevent memory leakage. Through this patch, the code will work as intented. Change-Id: Id2524f579bd68e0f757910dbdf93e482dc402755 Signed-off-by: Suyeon Hwang --- server/stte.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/stte.c b/server/stte.c index 59caa14..c2619c8 100755 --- a/server/stte.c +++ b/server/stte.c @@ -90,8 +90,10 @@ static bool is_privilege_allowed(const char* uid, const char * privilege) fp = fopen(label_path, "r"); if (fp != NULL) { if (0 >= fread(smack_label, 1, sizeof(smack_label), fp)) + SLOG(LOG_ERROR, TAG_STTD, "[ERROR] fail to fread"); //LCOV_EXCL_LINE fclose(fp); + fp = NULL; } pid_t pid = getpid(); -- 2.7.4