aboutsummaryrefslogtreecommitdiff
path: root/subhook.h
diff options
context:
space:
mode:
authorgocha <gochaism@gmail.com>2017-03-31 14:34:54 +0900
committergocha <gochaism@gmail.com>2017-03-31 14:34:54 +0900
commit1edbc7246cd65a9a0f4c7ecd9e7e306952fe67b2 (patch)
treead45067e9018f256d5479dde32e1b6a75ad51f34 /subhook.h
parent50a8d0ca24c514fb0b6946626e7856d85988f5a8 (diff)
downloadsubhook-1edbc7246cd65a9a0f4c7ecd9e7e306952fe67b2.zip
subhook-1edbc7246cd65a9a0f4c7ecd9e7e306952fe67b2.tar.gz
subhook-1edbc7246cd65a9a0f4c7ecd9e7e306952fe67b2.tar.bz2
Fix null reference on the destruction of empty Hook
Diffstat (limited to 'subhook.h')
-rw-r--r--subhook.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/subhook.h b/subhook.h
index c74e5d1..b7934f0 100644
--- a/subhook.h
+++ b/subhook.h
@@ -145,8 +145,10 @@ class Hook {
: hook_(subhook_new(src, dst, (subhook_options_t)options)) {}
~Hook() {
- subhook_remove(hook_);
- subhook_free(hook_);
+ if (hook_ != 0) {
+ subhook_remove(hook_);
+ subhook_free(hook_);
+ }
}
void *GetSrc() { return subhook_get_src(hook_); }