diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-10-14 01:33:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 01:33:24 +0300 |
commit | 1b1682ed243ef8304bfce1be7a70626c95720d93 (patch) | |
tree | 7d59d93dca969c4f884218a9451f15f1833fc82c /src/common | |
parent | b75799528a1394919fd5eb4c8763a96ee80a9325 (diff) | |
parent | 230de7dd1ec428c3a6274de3724cda284dea33e6 (diff) | |
download | hercules-1b1682ed243ef8304bfce1be7a70626c95720d93.tar.gz hercules-1b1682ed243ef8304bfce1be7a70626c95720d93.tar.bz2 hercules-1b1682ed243ef8304bfce1be7a70626c95720d93.tar.xz hercules-1b1682ed243ef8304bfce1be7a70626c95720d93.zip |
Merge pull request #1477 from HerculesWS/memmgr-hpm-fixes
Fixed a memory manager crash when a memory leak occurs in a plugin
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/HPM.c | 3 | ||||
-rw-r--r-- | src/common/HPMSymbols.inc.h | 6 | ||||
-rw-r--r-- | src/common/HPMi.h | 1 | ||||
-rw-r--r-- | src/common/memmgr.h | 4 |
4 files changed, 6 insertions, 8 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c index ff1371b14..1fad7102f 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -567,6 +567,7 @@ struct hplugin *hplugin_load(const char* filename) /* id */ plugin->hpi->pid = plugin->idx; /* core */ + plugin->hpi->memmgr = HPMiMalloc; #ifdef CONSOLE_INPUT plugin->hpi->addCPCommand = console->input->addCommand; #endif // CONSOLE_INPUT @@ -1093,8 +1094,8 @@ void hpm_init(void) HPM->off = false; - memcpy(&iMalloc_HPM, iMalloc, sizeof(struct malloc_interface)); HPMiMalloc = &iMalloc_HPM; + *HPMiMalloc = *iMalloc; HPMiMalloc->malloc = HPM_mmalloc; HPMiMalloc->calloc = HPM_calloc; HPMiMalloc->realloc = HPM_realloc; diff --git a/src/common/HPMSymbols.inc.h b/src/common/HPMSymbols.inc.h index 7ccb960de..8dd0f1cd7 100644 --- a/src/common/HPMSymbols.inc.h +++ b/src/common/HPMSymbols.inc.h @@ -155,9 +155,6 @@ struct loginif_interface *loginif; #ifdef MAP_MAIL_H /* mail */ struct mail_interface *mail; #endif // MAP_MAIL_H -#ifdef COMMON_MEMMGR_H /* iMalloc */ -struct malloc_interface *iMalloc; -#endif // COMMON_MEMMGR_H #ifdef MAP_MAP_H /* map */ struct map_interface *map; #endif // MAP_MAP_H @@ -405,9 +402,6 @@ if ((server_type&(SERVER_TYPE_CHAR)) && !HPM_SYMBOL("loginif", loginif)) return #ifdef MAP_MAIL_H /* mail */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mail", mail)) return "mail"; #endif // MAP_MAIL_H -#ifdef COMMON_MEMMGR_H /* iMalloc */ -if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("iMalloc", iMalloc)) return "iMalloc"; -#endif // COMMON_MEMMGR_H #ifdef MAP_MAP_H /* map */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("map", map)) return "map"; #endif // MAP_MAP_H diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 19b9b20a5..143c325c1 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -231,6 +231,7 @@ struct HPMi_interface { /* Hooking */ struct HPMHooking_interface *hooking; + struct malloc_interface *memmgr; }; #ifdef HERCULES_CORE #define HPM_SYMBOL(n, s) (HPM->share((s), (n)), true) diff --git a/src/common/memmgr.h b/src/common/memmgr.h index 680947466..a5b7e4e7d 100644 --- a/src/common/memmgr.h +++ b/src/common/memmgr.h @@ -101,8 +101,10 @@ struct malloc_interface { void malloc_defaults(void); void memmgr_report(int extra); -#endif // HERCULES_CORE HPShared struct malloc_interface *iMalloc; +#else +#define iMalloc HPMi->memmgr +#endif // HERCULES_CORE #endif /* COMMON_MEMMGR_H */ |