aboutsummaryrefslogtreecommitdiff
path: root/subhook.h
diff options
context:
space:
mode:
authorZeex <zeex@rocketmail.com>2017-03-31 22:32:15 +0600
committerGitHub <noreply@github.com>2017-03-31 22:32:15 +0600
commit699a6bd35710f075e3b94d27616d270046b09d3d (patch)
tree6771f88243e34ca3435bee02da044c7ab5183bf7 /subhook.h
parent2f9d0c1f1cfb3366c189b8bd52a5e8c266d96e8a (diff)
parent1edbc7246cd65a9a0f4c7ecd9e7e306952fe67b2 (diff)
downloadsubhook-699a6bd35710f075e3b94d27616d270046b09d3d.zip
subhook-699a6bd35710f075e3b94d27616d270046b09d3d.tar.gz
subhook-699a6bd35710f075e3b94d27616d270046b09d3d.tar.bz2
Merge pull request #23 from gocha/fix-dtor-nullref
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 3fd0dc8..90a5eb7 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_); }