Skip to content

Commit 0d8e273

Browse files
author
Steven Moreland
committed
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
1 parent 06e3c3f commit 0d8e273

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

libs/input/KeyCharacterMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ std::unique_ptr<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel)
615615
ALOGE("%s: Null parcel", __func__);
616616
return nullptr;
617617
}
618-
std::string loadFileName = parcel->readCString();
618+
std::string loadFileName = parcel->readString8().c_str();
619619
std::unique_ptr<KeyCharacterMap> map =
620620
std::make_unique<KeyCharacterMap>(KeyCharacterMap(loadFileName));
621621
map->mType = static_cast<KeyCharacterMap::KeyboardType>(parcel->readInt32());
@@ -704,7 +704,7 @@ void KeyCharacterMap::writeToParcel(Parcel* parcel) const {
704704
ALOGE("%s: Null parcel", __func__);
705705
return;
706706
}
707-
parcel->writeCString(mLoadFileName.c_str());
707+
parcel->writeString8(String8(mLoadFileName.c_str()));
708708
parcel->writeInt32(static_cast<int32_t>(mType));
709709
parcel->writeBool(mLayoutOverlayApplied);
710710

0 commit comments

Comments
 (0)