summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/iat_patch.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/base/iat_patch.cc b/base/iat_patch.cc
index 562078f..713aa92 100644
--- a/base/iat_patch.cc
+++ b/base/iat_patch.cc
@@ -208,12 +208,17 @@ DWORD IATPatchFunction::Unpatch() {
DWORD error = RestoreImportedFunction(intercept_function_,
original_function_,
iat_thunk_);
-
- if (NO_ERROR == error) {
- intercept_function_ = NULL;
- original_function_ = NULL;
- iat_thunk_ = NULL;
- }
+ DCHECK(NO_ERROR == error);
+
+ // Hands off the intercept if we fail to unpatch.
+ // If IATPatchFunction::Unpatch fails during RestoreImportedFunction
+ // it means that we cannot safely unpatch the import address table
+ // patch. In this case its better to be hands off the intercept as
+ // trying to unpatch again in the destructor of IATPatchFunction is
+ // not going to be any safer
+ intercept_function_ = NULL;
+ original_function_ = NULL;
+ iat_thunk_ = NULL;
return error;
}