Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 6eeaf925 authored by Marissa Wall's avatar Marissa Wall
Browse files

gralloc: libgralloctypes encode hidl_vec is invalid

hidl_vec's setToExternal takes data pointer. It doesn't copy the
data. The data is only valid as long as the original data pointer
is valid. libgralloctypes was calling setToExternal with a
std::vector pointer. When the std::vector died, the data pointer
was no longer point to valid memory. Encode functions were returning
a hidl_vec whose data pointer was bad. It was missed during testing
because the memory happened to still have the original data.

This CL removes setToExternal. It is too costly to call resize()
every time instead because it causes new memory to be allocated.
Instead, this CL does a dry run to get the total size needed,
resizes the buffer and then inserts the data.

This CL also cleaned up code to make the dry run possible.

Bug: 141632767
Test: libgralloctypes_fuzzer and VtsHalGraphicsMapperV4_0TargetTest

Change-Id: I5da1146600fc2f5a363685f387f81b5b694fa359
parent da88195b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment