diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index c8a12e18dd..bcdfe55e91 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -526,8 +526,8 @@ void fill_str_dated_filename(char *out_filename, void path_basedir(char *path) { char *last = NULL; - - if (strlen(path) < 2) + /* was strlen(path) < 2 before */ + if (!path || path[0] == '\0' || path[1] == '\0') return; if ((last = find_last_slash(path))) @@ -805,8 +805,15 @@ size_t path_relative_to(char *out, #ifdef _WIN32 /* For different drives, return absolute path */ - if (strlen(path) >= 2 && strlen(base) >= 2 - && path[1] == ':' && base[1] == ':' + if ( + path + && base + && path[0] != '\0' + && path[1] != '\0' /* was strlen(path) >= 2 before */ + && base[0] != '\0' + && base[1] != '\0' /* was strlen(base) >= 2 before */ + && path[1] == ':' + && base[1] == ':' && path[0] != base[0]) return strlcpy(out, path, size); #endif @@ -1151,7 +1158,8 @@ void fill_pathname_abbreviated_or_relative(char *out_path, const char *in_refpat void path_basedir_wrapper(char *path) { char *last = NULL; - if (strlen(path) < 2) + /* was strlen(path) < 2 before */ + if (!path || path[0] == '\0' || path[1] == '\0') return; #ifdef HAVE_COMPRESSION