Zero-initialize hidl_vec data

Bug: 131356202
Test: manually check padding in structs allocated in these arrays
Test: libhwbinder_benchmark, well within variance (this test allocates
    arrays).

Before:
---------------------------------------------------------------------
Benchmark                           Time             CPU   Iterations
---------------------------------------------------------------------
BM_sendVec_binderize/4          34935 ns        15081 ns        36091
BM_sendVec_binderize/8          39140 ns        16846 ns        38865
BM_sendVec_binderize/16         36495 ns        15833 ns        44182
BM_sendVec_binderize/32         39785 ns        17182 ns        38870
BM_sendVec_binderize/64         35647 ns        15466 ns        38215
BM_sendVec_binderize/128        39145 ns        16873 ns        44856
BM_sendVec_binderize/256        38836 ns        16801 ns        41596
BM_sendVec_binderize/512        41014 ns        17831 ns        40161
BM_sendVec_binderize/1024       37534 ns        16270 ns        41794
BM_sendVec_binderize/2048       37662 ns        16471 ns        42331
BM_sendVec_binderize/4096       38551 ns        16809 ns        35635
BM_sendVec_binderize/8192       36139 ns        15865 ns        42185
BM_sendVec_binderize/16384      51743 ns        22600 ns        31556
BM_sendVec_binderize/32768      46644 ns        20616 ns        30220
BM_sendVec_binderize/65536      68763 ns        30412 ns        25429

After:
---------------------------------------------------------------------
Benchmark                           Time             CPU   Iterations
---------------------------------------------------------------------
BM_sendVec_binderize/4          39549 ns        17214 ns        35193
BM_sendVec_binderize/8          38786 ns        16822 ns        37402
BM_sendVec_binderize/16         37787 ns        16492 ns        37100
BM_sendVec_binderize/32         40796 ns        17567 ns        36399
BM_sendVec_binderize/64         41024 ns        17797 ns        45328
BM_sendVec_binderize/128        36169 ns        15707 ns        39602
BM_sendVec_binderize/256        37136 ns        16094 ns        47081
BM_sendVec_binderize/512        37998 ns        16443 ns        48487
BM_sendVec_binderize/1024       35190 ns        15318 ns        40091
BM_sendVec_binderize/2048       37665 ns        16399 ns        39498
BM_sendVec_binderize/4096       45963 ns        19877 ns        36884
BM_sendVec_binderize/8192       40075 ns        17620 ns        34013
BM_sendVec_binderize/16384      46224 ns        20315 ns        34384
BM_sendVec_binderize/32768      49775 ns        21994 ns        35334
BM_sendVec_binderize/65536      60181 ns        27238 ns        22205

Change-Id: Ica6c55e7346b9e1ba91192472e2b229cb786802c
Merged-In: Ica6c55e7346b9e1ba91192472e2b229cb786802c
(cherry picked from commit 7a3202296f3b38cef284a18c71e99b6df51c5197)
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 1e2d103..bf3d8dc 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -306,7 +306,7 @@
             details::logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
         }
         mSize = static_cast<uint32_t>(list.size());
-        mBuffer = new T[mSize];
+        mBuffer = new T[mSize]();
         mOwnsBuffer = true;
 
         size_t idx = 0;
@@ -332,7 +332,7 @@
             details::logAlwaysFatal("size can't be negative.");
         }
         mSize = static_cast<uint32_t>(size);
-        mBuffer = new T[mSize];
+        mBuffer = new T[mSize]();
         mOwnsBuffer = true;
 
         size_t idx = 0;
@@ -453,7 +453,7 @@
         if (size > UINT32_MAX) {
             details::logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
         }
-        T *newBuffer = new T[size];
+        T* newBuffer = new T[size]();
 
         for (size_t i = 0; i < std::min(static_cast<uint32_t>(size), mSize); ++i) {
             newBuffer[i] = mBuffer[i];
@@ -529,7 +529,7 @@
         mSize = static_cast<uint32_t>(size);
         mOwnsBuffer = true;
         if (mSize > 0) {
-            mBuffer = new T[size];
+            mBuffer = new T[size]();
             for (size_t i = 0; i < size; ++i) {
                 mBuffer[i] = data[i];
             }