summaryrefslogtreecommitdiff
path: root/services/inputflinger/InputCommonConverter.cpp
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2023-06-15 20:41:02 -0700
committer Siarhei Vishniakou <svv@google.com> 2023-06-22 08:49:43 -0700
commit3218fc08efb1d3c15f9060343c0850e018f0301c (patch)
treeb8a18ced029656f480b2b6bef811b68ff06726de /services/inputflinger/InputCommonConverter.cpp
parentc16c3d24b72c5ad015cf76208b9ee14fcaf075c6 (diff)
Store coords and properties as vector in args
Before this CL, NotifyMotionArgs stored PointerCoords and PointerProperties in a fixed-size array. Upon creation of a new object, some of that data typically remained uninitialized. At the same time, the copy assignment operator was defaulted, which meant that the uninitialized data was getting accessed in order to copy the object. The sanitizers identify this as a problem and crash. To fix this, store these objects inside vectors. Bug: 271455682 Test: atest inputflinger_tests Change-Id: I9dba29f75df59a21f8ed7fd0f46fd1f6d45f2eef
Diffstat (limited to 'services/inputflinger/InputCommonConverter.cpp')
-rw-r--r--services/inputflinger/InputCommonConverter.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/services/inputflinger/InputCommonConverter.cpp b/services/inputflinger/InputCommonConverter.cpp
index 781288076c..6ccd9e7697 100644
--- a/services/inputflinger/InputCommonConverter.cpp
+++ b/services/inputflinger/InputCommonConverter.cpp
@@ -289,9 +289,9 @@ static std::vector<common::VideoFrame> convertVideoFrames(
static void getHalPropertiesAndCoords(const NotifyMotionArgs& args,
std::vector<common::PointerProperties>& outPointerProperties,
std::vector<common::PointerCoords>& outPointerCoords) {
- outPointerProperties.reserve(args.pointerCount);
- outPointerCoords.reserve(args.pointerCount);
- for (size_t i = 0; i < args.pointerCount; i++) {
+ outPointerProperties.reserve(args.getPointerCount());
+ outPointerCoords.reserve(args.getPointerCount());
+ for (size_t i = 0; i < args.getPointerCount(); i++) {
common::PointerProperties properties;
properties.id = args.pointerProperties[i].id;
properties.toolType = getToolType(args.pointerProperties[i].toolType);