From 8f76b5cfe66ef450d419633f6f68eeb3eae40bb5 Mon Sep 17 00:00:00 2001 From: "o.v.yevtushenko" Date: Fri, 16 Aug 2019 11:53:56 +0300 Subject: [PATCH] Fix bad command length calculation SET_LAYER_PER_FRAME_METADATA_BLOBS command length was calculated wrong. With wrong length it's impossible to read current and any next commands right. Test: manual Bug: 144367999 Change-Id: I09a23bbf507996972ce7de0634f8866bbb13152a Signed-off-by: o.v.yevtushenko --- .../composer-command-buffer/2.3/ComposerCommandBuffer.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/graphics/composer/2.3/utils/command-buffer/include/composer-command-buffer/2.3/ComposerCommandBuffer.h b/graphics/composer/2.3/utils/command-buffer/include/composer-command-buffer/2.3/ComposerCommandBuffer.h index 11863faced..e1a870e072 100644 --- a/graphics/composer/2.3/utils/command-buffer/include/composer-command-buffer/2.3/ComposerCommandBuffer.h +++ b/graphics/composer/2.3/utils/command-buffer/include/composer-command-buffer/2.3/ComposerCommandBuffer.h @@ -79,6 +79,7 @@ class CommandWriterBase : public V2_2::CommandWriterBase { void setLayerPerFrameMetadataBlobs( const hidl_vec& metadata) { + // in units of uint32_t's size_t commandLength = 0; if (metadata.size() > std::numeric_limits::max()) { @@ -86,12 +87,12 @@ class CommandWriterBase : public V2_2::CommandWriterBase { return; } - // number of blobs - commandLength += metadata.size(); + // space for numElements + commandLength += 1; for (auto metadataBlob : metadata) { - commandLength += sizeof(int32_t); // key of metadata blob - commandLength += 1; // size information of metadata blob + commandLength += 1; // key of metadata blob + commandLength += 1; // size information of metadata blob // metadata content size size_t metadataSize = metadataBlob.blob.size() / sizeof(uint32_t);