From baae1fc84f5da417cefeb9d2257d653942181e81 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 20 Nov 2018 03:49:44 -0500 Subject: [PATCH] Modernize selinux stub --- native/jni/utils/selinux.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/native/jni/utils/selinux.cpp b/native/jni/utils/selinux.cpp index 408437008..5e184e2d8 100644 --- a/native/jni/utils/selinux.cpp +++ b/native/jni/utils/selinux.cpp @@ -13,14 +13,14 @@ // Stub implementations -static void v_s(char *) {} +static void v_s(char *s) { delete[] s; } static int i_s(const char *) { return 0; } static int i_ss(const char *, const char *) { return 0; } static int i_ssp(const char *, char ** sp) { - *sp = (char *) xcalloc(1, 1); + *sp = new char[1](); return 0; } @@ -35,7 +35,7 @@ int (*lsetfilecon)(const char *, const char *) = i_ss; void dload_selinux() { void *handle = dlopen("libselinux.so", RTLD_LAZY); - if (handle == NULL) + if (handle == nullptr) return; *(void **) &freecon = dlsym(handle, "freecon"); *(void **) &setcon = dlsym(handle, "setcon"); @@ -119,4 +119,4 @@ void restorecon() { fd = xopen(DATABIN, O_RDONLY | O_CLOEXEC); restore_magiskcon(fd); close(fd); -} \ No newline at end of file +}