summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2020-04-03 10:55:12 -0700
committerSteven Moreland <smoreland@google.com>2020-04-03 11:01:18 -0700
commite873cf33d8519d3e85f4062df03c90a9f817de62 (patch)
tree3281c74a4235a7a06d531fb2b5aa82ff808fee59 /base
parentbb842a65ed0be3e762b1f2214fa20a45cd5ade83 (diff)
downloadlibhidl-e873cf33d8519d3e85f4062df03c90a9f817de62.tar.gz
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
Diffstat (limited to 'base')
-rw-r--r--base/include/hidl/HidlSupport.h2
1 files changed, 1 insertions, 1 deletions
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 @@ struct hidl_vec {
}
T *releaseData() {
- if (!mOwnsBuffer && mSize > 0) {
+ if (!mOwnsBuffer && mBuffer != nullptr) {
resize(mSize);
}
mOwnsBuffer = false;