From 592760a8a6ba220c08107f63b08ca7f9c2421194 Mon Sep 17 00:00:00 2001 From: lvyitian <535481388@qq.com> Date: Sun, 20 Aug 2023 17:00:59 +0800 Subject: [PATCH] fix memory leak --- module.gradle | 2 +- module/src/main/cpp/open_hook.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/module.gradle b/module.gradle index 2e2d695..6102164 100644 --- a/module.gradle +++ b/module.gradle @@ -4,6 +4,6 @@ ext { moduleName = "YuanShenRedirect" moduleAuthor = "Perfare" moduleDescription = "Redirect file access of YuanShen" - moduleVersion = "v1.1.0" + moduleVersion = "v1.2.0" moduleVersionCode = 1 } diff --git a/module/src/main/cpp/open_hook.c b/module/src/main/cpp/open_hook.c index 45a1c61..af94b50 100644 --- a/module/src/main/cpp/open_hook.c +++ b/module/src/main/cpp/open_hook.c @@ -57,16 +57,36 @@ char* str_replace(char* orig, char* rep, char* with) { char* path_replace(const char* path) { path=str_replace(path,"/data/media/0/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + char* tmp=path; path=str_replace(path,"/storage/emulated/0/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/storage/sdcard0/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/storage/self/primary/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/data/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/mnt/user/0/emulated/0/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/mnt/user/0/sdcard0/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/mnt/user/0/self/primary/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/mnt/sdcard/Android/data/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/data/user/0/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); + tmp=path; path=str_replace(path,"/data/user_de/0/com.miHoYo.Yuanshen/files/VideoAssets","/data/sdext2/ys/VideoAssets"); + if(tmp) free(tmp); return path; } int statvfs_hook(const char* path, void* status)