Fix hypothetical double-own in hidl_vec.
To my knowledge, no one has hit this, but this type (probably unwisely)
allows itself to be empty w/ null buffer or empty w/ non-null buffer
(e.g. via setExternal/resize(0)). So, releaseData should be checking for
null buffer, not size 0.
Bug: 152911913
Test: libhidl_test
Change-Id: I5792b5aac5b3278333a75ff84f09d3d5e5b3a8a2
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 9343f0f..0a0beeb 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -412,7 +412,7 @@
}
T *releaseData() {
- if (!mOwnsBuffer && mSize > 0) {
+ if (!mOwnsBuffer && mBuffer != nullptr) {
resize(mSize);
}
mOwnsBuffer = false;