Zero-init HIDL core types.
hidl_pointer - already zero initialized
hidl_string - now memset to 0
hidl_array - has no pad to initialize, default initialize since we
now expect structs to be default initialized to sane values.
hidl_vec - now memset to 0
hidl_memory - has three aligned(8) items which are always set
hidl_version - unused, but has two uint16_t entries
Since they are passed across processes.
Bug: 130161842
Test: print out values
Change-Id: I56bacf9ca7ac51d73449d11883c6224e214b8773
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index 58afa69..141242e 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -137,10 +137,11 @@
static const char *const kEmptyString = "";
-hidl_string::hidl_string()
- : mBuffer(kEmptyString),
- mSize(0),
- mOwnsBuffer(false) {
+hidl_string::hidl_string() {
+ memset(this, 0, sizeof(*this));
+ // mSize is zero
+ // mOwnsBuffer is false
+ mBuffer = kEmptyString;
}
hidl_string::~hidl_string() {