Skip to content

Commit

Permalink
fix null safety issue when rom/home path is somehow invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Jun 12, 2024
1 parent 61da615 commit 8a14006
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/common/vb_set.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>

#ifdef __3DS__
#include <3ds.h>
Expand Down Expand Up @@ -336,7 +337,9 @@ int loadFileOptions(void) {
}

int loadGameOptions(void) {
int ret = ini_parse(getGameIniPath(), handler, &tVBOpt);
char *ini_path = getGameIniPath();
int ret = ENOENT;
if (ini_path) ret = ini_parse(ini_path, handler, &tVBOpt);
if (!ret) tVBOpt.GAME_SETTINGS = true;
else tVBOpt.GAME_SETTINGS = false;
tVBOpt.MODIFIED = false;
Expand Down Expand Up @@ -437,11 +440,15 @@ int saveFileOptions(void) {
}

int deleteGameOptions(void) {
return remove(getGameIniPath());
char *ini_path = getGameIniPath();
if (ini_path) return remove(getGameIniPath());
else return ENOENT;
}

int saveGameOptions(void) {
FILE* f = fopen(getGameIniPath(), "w");
char *ini_path = getGameIniPath();
if (!ini_path) return 1;
FILE* f = fopen(ini_path, "w");
if (!f)
return 1;

Expand Down

0 comments on commit 8a14006

Please sign in to comment.