fix potential nullptrs and off by one

This commit is contained in:
Ada 2024-03-08 15:24:21 +00:00
parent cd25e11f8e
commit 68e35d806a
No known key found for this signature in database
GPG key ID: 066E56D5C9F4E50D
2 changed files with 2 additions and 2 deletions

View file

@ -246,7 +246,7 @@ Rust::Result<std::vector<u8>, HorizonResult> ExtSaveDataArchive::loadIcon() cons
const fs::path iconPath = IOFile::getAppData() / backingFolder / "icon";
IOFile file(iconPath, "rb");
const s32 size = static_cast<s32>(file.size().value_or(-1));
if (size < 0) {
if (size <= 0) {
return Err(Result::FS::NotFoundInvalid);
}

View file

@ -578,7 +578,7 @@ void FSService::createExtSaveData(u32 messagePointer) {
if (selected != nullptr) {
selected->format(path, info);
if (smdhSize > 0) {
if (smdhSize > 0 && smdhPointer != 0) {
const FSPath smdh = readPath(PathType::Binary, smdhPointer, smdhSize);
selected->saveIcon(smdh.binary);
}