mirror of
https://github.com/libretro/RetroArch
synced 2025-01-27 12:35:23 +00:00
(GX) fix potential null-pointer exceptions
This commit is contained in:
parent
a88e9e024f
commit
059cfd3c24
@ -314,9 +314,14 @@ int rarch_main(int argc, char **argv);
|
|||||||
static void get_environment_settings(void)
|
static void get_environment_settings(void)
|
||||||
{
|
{
|
||||||
getcwd(default_paths.core_dir, MAXPATHLEN);
|
getcwd(default_paths.core_dir, MAXPATHLEN);
|
||||||
*(strrchr(default_paths.core_dir, '/')) = 0;
|
char *last_slash = strrchr(default_paths.core_dir, '/');
|
||||||
|
if (last_slash)
|
||||||
|
*last_slash = 0;
|
||||||
char *device_end = strchr(default_paths.core_dir, '/');
|
char *device_end = strchr(default_paths.core_dir, '/');
|
||||||
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
|
if (device_end)
|
||||||
|
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
|
||||||
|
else
|
||||||
|
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "/retroarch");
|
||||||
snprintf(default_paths.config_file, sizeof(default_paths.config_file), "%s/retroarch.cfg", default_paths.port_dir);
|
snprintf(default_paths.config_file, sizeof(default_paths.config_file), "%s/retroarch.cfg", default_paths.port_dir);
|
||||||
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
|
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
|
||||||
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
|
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
|
||||||
|
@ -115,9 +115,14 @@ static void init_settings(void)
|
|||||||
static void get_environment_settings(void)
|
static void get_environment_settings(void)
|
||||||
{
|
{
|
||||||
getcwd(default_paths.core_dir, MAXPATHLEN);
|
getcwd(default_paths.core_dir, MAXPATHLEN);
|
||||||
*(strrchr(default_paths.core_dir, '/')) = 0;
|
char *last_slash = strrchr(default_paths.core_dir, '/');
|
||||||
|
if (last_slash)
|
||||||
|
*last_slash = 0;
|
||||||
char *device_end = strchr(default_paths.core_dir, '/');
|
char *device_end = strchr(default_paths.core_dir, '/');
|
||||||
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
|
if (device_end)
|
||||||
|
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
|
||||||
|
else
|
||||||
|
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "/retroarch");
|
||||||
snprintf(default_paths.config_file, sizeof(default_paths.config_file), "%s/retroarch.cfg", default_paths.port_dir);
|
snprintf(default_paths.config_file, sizeof(default_paths.config_file), "%s/retroarch.cfg", default_paths.port_dir);
|
||||||
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
|
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
|
||||||
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
|
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user