mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-20 11:03:56 +00:00
fix: autoloader null pointer dereferences and Windows API conflict
- Use VfsFilesystemCreateDirectoryWrapper to avoid Windows API collision - Add null check for dest_file before accessing it - Prevent crashes when file/directory creation fails during autoload Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -6314,7 +6314,7 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
std::string sdmc_path = Common::FS::GetCitronPathString(Common::FS::CitronPath::SDMCDir);
|
std::string sdmc_path = Common::FS::GetCitronPathString(Common::FS::CitronPath::SDMCDir);
|
||||||
std::string dest_path_str = fmt::format("{}/autoloader/{:016X}/{}/{}", sdmc_path, program_id, type_folder, nsp_name.toStdString());
|
std::string dest_path_str = fmt::format("{}/autoloader/{:016X}/{}/{}", sdmc_path, program_id, type_folder, nsp_name.toStdString());
|
||||||
|
|
||||||
auto dest_dir = vfs->CreateDirectory(dest_path_str, FileSys::OpenMode::ReadWrite);
|
auto dest_dir = VfsFilesystemCreateDirectoryWrapper(vfs, dest_path_str, FileSys::OpenMode::ReadWrite);
|
||||||
if (!dest_dir) {
|
if (!dest_dir) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED to create destination directory: {}", dest_path_str);
|
LOG_ERROR(Loader, "AUTOLOADER: FAILED to create destination directory: {}", dest_path_str);
|
||||||
failed_files.append(QFileInfo(file).fileName() + tr(" (Directory Creation Error)"));
|
failed_files.append(QFileInfo(file).fileName() + tr(" (Directory Creation Error)"));
|
||||||
@@ -6326,6 +6326,12 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
auto source_file = nca->GetBaseFile();
|
auto source_file = nca->GetBaseFile();
|
||||||
auto dest_file = dest_dir->CreateFileRelative(source_file->GetName());
|
auto dest_file = dest_dir->CreateFileRelative(source_file->GetName());
|
||||||
|
|
||||||
|
if (!dest_file) {
|
||||||
|
LOG_ERROR(Loader, "AUTOLOADER: FAILED to create destination file for {}.", source_file->GetName());
|
||||||
|
copy_failed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!dest_file->Resize(source_file->GetSize())) {
|
if (!dest_file->Resize(source_file->GetSize())) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED to resize destination file for {}.", source_file->GetName());
|
LOG_ERROR(Loader, "AUTOLOADER: FAILED to resize destination file for {}.", source_file->GetName());
|
||||||
copy_failed = true;
|
copy_failed = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user