From 68e35d806a26ec493789afe8e07fbea8ce5ad66e Mon Sep 17 00:00:00 2001 From: Ada Date: Fri, 8 Mar 2024 15:24:21 +0000 Subject: [PATCH] fix potential nullptrs and off by one --- src/core/fs/archive_ext_save_data.cpp | 2 +- src/core/services/fs.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/fs/archive_ext_save_data.cpp b/src/core/fs/archive_ext_save_data.cpp index 38de9b5c..6fe4d97c 100644 --- a/src/core/fs/archive_ext_save_data.cpp +++ b/src/core/fs/archive_ext_save_data.cpp @@ -246,7 +246,7 @@ Rust::Result, HorizonResult> ExtSaveDataArchive::loadIcon() cons const fs::path iconPath = IOFile::getAppData() / backingFolder / "icon"; IOFile file(iconPath, "rb"); const s32 size = static_cast(file.size().value_or(-1)); - if (size < 0) { + if (size <= 0) { return Err(Result::FS::NotFoundInvalid); } diff --git a/src/core/services/fs.cpp b/src/core/services/fs.cpp index 40df67c7..742f1fb1 100644 --- a/src/core/services/fs.cpp +++ b/src/core/services/fs.cpp @@ -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); }