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

Commit 31b9016a authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

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
parent 56978ea1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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 {