Null pointer fix

This commit is contained in:
Daniil Vinogradov 2025-02-15 18:46:02 +01:00
parent 4ffb0ff617
commit 27312d4f31
3 changed files with 10 additions and 4 deletions

View File

@ -227,8 +227,9 @@ class Ryujinx {
let gameInfo = get_game_info(handle.fileDescriptor, extensionPtr)
let game = Game.convertGameInfoToGame(gameInfo: gameInfo, url: fileURLCandidate)
guard let game = Game.convertGameInfoToGame(gameInfo: gameInfo, url: fileURLCandidate)
else { continue }
games.append(game)
} catch {
print(error)

View File

@ -22,10 +22,12 @@ public struct Game: Identifiable, Equatable, Hashable {
var icon: UIImage?
static func convertGameInfoToGame(gameInfo: GameInfo, url: URL) -> Game {
static func convertGameInfoToGame(gameInfo: GameInfo, url: URL) -> Game? {
guard gameInfo.FileSize != 0 else { return nil }
var gameInfo = gameInfo
var gameTemp = Game(containerFolder: url.deletingLastPathComponent(), fileType: .item, fileURL: url, titleName: "", titleId: "", developer: "", version: "")
gameTemp.titleName = withUnsafePointer(to: &gameInfo.TitleName) {
$0.withMemoryRebound(to: UInt8.self, capacity: MemoryLayout.size(ofValue: $0)) {
String(cString: $0)

View File

@ -321,6 +321,9 @@ namespace Ryujinx.Headless.SDL2
var stream = OpenFile(descriptor);
var gameInfo = GetGameInfo(stream, extension);
if (gameInfo == null) {
return new GameInfoNative(0, "", "", "", "", new byte[0]);
}
return new GameInfoNative(
(ulong)gameInfo.FileSize,