Zero-init HIDL core types (hidl_handle).
Has 7 padded bits at the end.
Bug: 130161842
Test: boot
Change-Id: I8dd52e196e1585028d91d97f00861021c21ec09c
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index 58afa69..65863b4 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -36,27 +36,28 @@
} // namespace details
hidl_handle::hidl_handle() {
- mHandle = nullptr;
- mOwnsHandle = false;
+ memset(this, 0, sizeof(*this));
+ // mHandle = nullptr;
+ // mOwnsHandle = false;
}
hidl_handle::~hidl_handle() {
freeHandle();
}
-hidl_handle::hidl_handle(const native_handle_t *handle) {
+hidl_handle::hidl_handle(const native_handle_t* handle) : hidl_handle() {
mHandle = handle;
mOwnsHandle = false;
}
// copy constructor.
-hidl_handle::hidl_handle(const hidl_handle &other) {
+hidl_handle::hidl_handle(const hidl_handle& other) : hidl_handle() {
mOwnsHandle = false;
*this = other;
}
// move constructor.
-hidl_handle::hidl_handle(hidl_handle&& other) noexcept {
+hidl_handle::hidl_handle(hidl_handle&& other) noexcept : hidl_handle() {
mOwnsHandle = false;
*this = std::move(other);
}