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

Commit 0d8e2730 authored by Steven Moreland's avatar Steven Moreland
Browse files

libinput: avoid null segmentation fault

readCString may return nullptr, and it's deprecated
and old anyway.

Please also consider converting this code to use
AIDL-defined parcelables. go/aidl-it!

Bug: 301519740
Test: w/ fuzzer
Change-Id: I76050c3b7fe40964fd751e678688d2e1d97b9479
parent 06e3c3fa
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -615,7 +615,7 @@ std::unique_ptr<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel)
        ALOGE("%s: Null parcel", __func__);
        return nullptr;
    }
    std::string loadFileName = parcel->readCString();
    std::string loadFileName = parcel->readString8().c_str();
    std::unique_ptr<KeyCharacterMap> map =
            std::make_unique<KeyCharacterMap>(KeyCharacterMap(loadFileName));
    map->mType = static_cast<KeyCharacterMap::KeyboardType>(parcel->readInt32());
@@ -704,7 +704,7 @@ void KeyCharacterMap::writeToParcel(Parcel* parcel) const {
        ALOGE("%s: Null parcel", __func__);
        return;
    }
    parcel->writeCString(mLoadFileName.c_str());
    parcel->writeString8(String8(mLoadFileName.c_str()));
    parcel->writeInt32(static_cast<int32_t>(mType));
    parcel->writeBool(mLayoutOverlayApplied);