Merge "Fix bad command length calculation"

This commit is contained in:
Peiyong Lin 2019-12-02 22:35:39 +00:00 committed by Gerrit Code Review
commit b44c4d4cd3

View file

@ -79,6 +79,7 @@ class CommandWriterBase : public V2_2::CommandWriterBase {
void setLayerPerFrameMetadataBlobs( void setLayerPerFrameMetadataBlobs(
const hidl_vec<IComposerClient::PerFrameMetadataBlob>& metadata) { const hidl_vec<IComposerClient::PerFrameMetadataBlob>& metadata) {
// in units of uint32_t's
size_t commandLength = 0; size_t commandLength = 0;
if (metadata.size() > std::numeric_limits<uint32_t>::max()) { if (metadata.size() > std::numeric_limits<uint32_t>::max()) {
@ -86,12 +87,12 @@ class CommandWriterBase : public V2_2::CommandWriterBase {
return; return;
} }
// number of blobs // space for numElements
commandLength += metadata.size(); commandLength += 1;
for (auto metadataBlob : metadata) { for (auto metadataBlob : metadata) {
commandLength += sizeof(int32_t); // key of metadata blob commandLength += 1; // key of metadata blob
commandLength += 1; // size information of metadata blob commandLength += 1; // size information of metadata blob
// metadata content size // metadata content size
size_t metadataSize = metadataBlob.blob.size() / sizeof(uint32_t); size_t metadataSize = metadataBlob.blob.size() / sizeof(uint32_t);