Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
treat memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
eebssk1 committed Apr 25, 2021
1 parent fe20b11 commit 91c9f14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ ext {
moduleName = "mph"
moduleAuthor = "eebssk1"
moduleDescription = "Hook system prop function with dobby to simulate miui for MiPushFOSS"
moduleVersion = "v25.2.0"
moduleVersionCode = 27
moduleVersion = "v25.2.1"
moduleVersionCode = 28
}
13 changes: 12 additions & 1 deletion module/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,23 @@ namespace Hook {
char *value;
} prop_info_compat;

struct prop_info_compat *mpi;

prop_info *(*orig__system_property_find)(const char *name);

prop_info *my__system_property_find(const char *name) {
if(UNLIKELY(mpi)){
free(mpi->name);
free(mpi->value);
free(mpi);
mpi = NULL;
}
int psz = strlen(name) + 1;
char mname[psz];
strcpy(mname,name);
auto prop = Config::Properties::Find(mname);
if(UNLIKELY(prop)){
auto *mpi = (struct prop_info_compat *)malloc(sizeof(prop_info_compat));
mpi = (struct prop_info_compat *)malloc(sizeof(prop_info_compat));
mpi->name = (char *)malloc(psz);
mpi->value = (char *)malloc(prop->value.length() + 1);
strcpy(mpi->name,mname);
Expand Down Expand Up @@ -203,6 +210,10 @@ static int saved_uid;
static void appProcessPre(JNIEnv *env, jint *uid, jstring *jNiceName, jstring *jAppDataDir) {

saved_uid = *uid;
if(LIKELY(saved_package_name)){
free(saved_package_name);
saved_package_name=NULL;
};

#ifdef DEBUG
static char saved_process_name[256];
Expand Down

0 comments on commit 91c9f14

Please sign in to comment.