diff options
author | Steven Moreland <smoreland@google.com> | 2020-04-03 10:55:12 -0700 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2020-04-03 11:01:18 -0700 |
commit | e873cf33d8519d3e85f4062df03c90a9f817de62 (patch) | |
tree | 3281c74a4235a7a06d531fb2b5aa82ff808fee59 /base | |
parent | bb842a65ed0be3e762b1f2214fa20a45cd5ade83 (diff) | |
download | libhidl-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.h | 2 |
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; |