Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit b081f8d

Browse files
committed
Fix a possible memory leak
1 parent 3423d6e commit b081f8d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

daemon/src/main/jni/denylist.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ static bool prepare_ksu_fd() {
110110
return ksu_fd >= 0;
111111
}
112112

113+
static void ksu_close_fd() {
114+
if (ksu_fd >= 0) {
115+
close(ksu_fd);
116+
ksu_fd = -1;
117+
}
118+
}
119+
113120
static bool ksu_get_existence() {
114121
if (prepare_ksu_fd()) {
115122
struct ksu_get_info_cmd g_version {};
@@ -123,7 +130,7 @@ static bool ksu_get_existence() {
123130

124131
return true;
125132
} else {
126-
ksu_fd = -1;
133+
ksu_close_fd();
127134
}
128135
}
129136

@@ -534,8 +541,5 @@ Java_org_lsposed_lspd_service_DenylistManager_isInDenylistFromClasspathDir(JNIEn
534541

535542
extern "C" JNIEXPORT void JNICALL
536543
Java_org_lsposed_lspd_service_DenylistManager_clearFd(JNIEnv *env, jclass) {
537-
if (ksu_fd >= 0) {
538-
close(ksu_fd);
539-
ksu_fd = -1;
540-
}
544+
ksu_close_fd();
541545
}

0 commit comments

Comments
 (0)