summaryrefslogtreecommitdiff
path: root/src/qcommon
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2014-07-12 22:06:26 +0200
committer/dev/humancontroller <devhc@example.com>2017-02-07 17:34:59 +0100
commit7190d27a586ee1a4be4a550833f5ec91fca5402e (patch)
tree54175b504f6781dea77bf3897bd37156633c9d64 /src/qcommon
parent75db20e2ad78fbb518bdd948767b07c9635defdd (diff)
fix crashing when an fs_*path is relative, but does not have an initial "." component (eg., fs_homepath = "dir1/dir2"), or when a path contains multiple consecutive separators (eg. "dir//file")
Diffstat (limited to 'src/qcommon')
-rw-r--r--src/qcommon/files.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/qcommon/files.c b/src/qcommon/files.c
index 4edf0318..5ab6e980 100644
--- a/src/qcommon/files.c
+++ b/src/qcommon/files.c
@@ -509,13 +509,12 @@ qboolean FS_CreatePath (char *OSPath) {
Q_strncpyz( path, OSPath, sizeof( path ) );
FS_ReplaceSeparators( path );
- // Skip creation of the root directory as it will always be there
- ofs = strchr( path, PATH_SEP );
- if ( ofs != NULL ) {
+ ofs = path;
+ while ( *ofs == PATH_SEP ) {
ofs++;
}
- for (; ofs != NULL && *ofs ; ofs++) {
+ for ( ; *ofs ; ofs++) {
if (*ofs == PATH_SEP) {
// create the directory
*ofs = 0;
@@ -524,6 +523,9 @@ qboolean FS_CreatePath (char *OSPath) {
path );
}
*ofs = PATH_SEP;
+ while ( *(ofs + 1) == PATH_SEP ) {
+ ofs++;
+ }
}
}