diff options
author | Zeex <zeex@rocketmail.com> | 2013-01-15 03:31:31 +0700 |
---|---|---|
committer | Zeex <zeex@rocketmail.com> | 2013-01-15 03:56:15 +0700 |
commit | 8347e1a37008e2ae73e97080c4e8455fd2213815 (patch) | |
tree | a764ee0d74b618b36a75c23b81774418194f87cf /subhook_x86.c | |
parent | 21e76ee3888315c8c7573f022196ac43221c014e (diff) | |
download | subhook-8347e1a37008e2ae73e97080c4e8455fd2213815.zip subhook-8347e1a37008e2ae73e97080c4e8455fd2213815.tar.gz subhook-8347e1a37008e2ae73e97080c4e8455fd2213815.tar.bz2 |
Fix silly memory leak in subhook_install()
Diffstat (limited to 'subhook_x86.c')
-rw-r--r-- | subhook_x86.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/subhook_x86.c b/subhook_x86.c index 0b2c7a2..a040cb3 100644 --- a/subhook_x86.c +++ b/subhook_x86.c @@ -49,8 +49,11 @@ SUBHOOK_EXPORT int SUBHOOK_API subhook_install(struct subhook *hook) { src = subhook_get_source(hook); dst = subhook_get_destination(hook); - if ((hook->arch = malloc(sizeof(struct subhook_x86))) == NULL) - return -ENOMEM; + /* allocate machine-specific data on frist install */ + if (hook->arch == NULL) { + if ((hook->arch = malloc(sizeof(struct subhook_x86))) == NULL) + return -ENOMEM; + } subhook_unprotect(src, SUBHOOK_JUMP_SIZE); memcpy(((struct subhook_x86 *)hook->arch)->code, src, SUBHOOK_JUMP_SIZE); |