update_engine: check pointer for nullptr
Member processor_ in ScopedActionCompleter is a raw pointer that is not
owned by ScopedActionCompleter. However in ScopedActionCompleter's
d'tor, it assumes processor_ is not nullptr and call its ActionComplete
function.
Add a CHECK() in c'tor making sure the object in the first place is not nullptr.
BUG=None
TEST=emerge-kefka update_engine, unittest
Change-Id: Ifce060667c8b4280d42d1f0fbca3588bcbe89f3d
Reviewed-on: https://chromium-review.googlesource.com/1342943
Commit-Ready: Xiaochu Liu <xiaochu@chromium.org>
Tested-by: Xiaochu Liu <xiaochu@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
diff --git a/common/utils.h b/common/utils.h
index ecb97a3..017eebb 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -376,7 +376,9 @@
: processor_(processor),
action_(action),
code_(ErrorCode::kError),
- should_complete_(true) {}
+ should_complete_(true) {
+ CHECK(processor_);
+ }
~ScopedActionCompleter() {
if (should_complete_)
processor_->ActionComplete(action_, code_);