diff options
author | 2024-11-04 20:15:56 +0000 | |
---|---|---|
committer | 2024-11-05 08:31:15 +0000 | |
commit | 31b9016a7a3d6a1ecb6d2a59775ec496810f51f4 (patch) | |
tree | 10185744492e1363e1f98f539e0c0102bdeadd71 | |
parent | 56978ea18fd233f4cf6f6bd2ac2f2edaf85f37b6 (diff) |
Correctly convert std::string to rust::String
Invalid unicode data can lead to panic when trying to
convert std::string to rust::String
Test: None
Bug: 376989545
Flag: EXEMPT bugfix
Change-Id: I384924e9b72b5076abf15bd55b38307bfb773ac4
-rw-r--r-- | libs/input/KeyboardClassifier.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/input/KeyboardClassifier.cpp b/libs/input/KeyboardClassifier.cpp index 0c2c7be582..2a83919283 100644 --- a/libs/input/KeyboardClassifier.cpp +++ b/libs/input/KeyboardClassifier.cpp @@ -57,14 +57,14 @@ void KeyboardClassifier::notifyKeyboardChanged(DeviceId deviceId, uint32_t deviceClasses) { if (mRustClassifier) { RustInputDeviceIdentifier rustIdentifier; - rustIdentifier.name = identifier.name; - rustIdentifier.location = identifier.location; - rustIdentifier.unique_id = identifier.uniqueId; + rustIdentifier.name = rust::String::lossy(identifier.name); + rustIdentifier.location = rust::String::lossy(identifier.location); + rustIdentifier.unique_id = rust::String::lossy(identifier.uniqueId); rustIdentifier.bus = identifier.bus; rustIdentifier.vendor = identifier.vendor; rustIdentifier.product = identifier.product; rustIdentifier.version = identifier.version; - rustIdentifier.descriptor = identifier.descriptor; + rustIdentifier.descriptor = rust::String::lossy(identifier.descriptor); android::input::keyboardClassifier::notifyKeyboardChanged(**mRustClassifier, deviceId, rustIdentifier, deviceClasses); } else { |