diff options
author | glx <glx@openttd.org> | 2009-10-04 12:17:10 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2009-10-04 12:17:10 +0000 |
commit | 1e665c7639a81da6e50e888976569b64288d8052 (patch) | |
tree | b506e90ccfefbb2d79364c3677e1410dab84f2a0 /src | |
parent | c344ae2e1db39db8f01229934b154d0c18db0e46 (diff) | |
download | openttd-1e665c7639a81da6e50e888976569b64288d8052.tar.xz |
(svn r17689) -Fix (r16307): depend could segfault in some case (TrueBrain)
Diffstat (limited to 'src')
-rw-r--r-- | src/depend/depend.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/depend/depend.cpp b/src/depend/depend.cpp index 133a7b676..8510f0ecd 100644 --- a/src/depend/depend.cpp +++ b/src/depend/depend.cpp @@ -426,7 +426,8 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local) /* Remove '..' from the begin of the filename. */ while (*p == '.') { if (*(++p) == '.') { - *(strrchr(path, '/')) = '\0'; + char *s = strrchr(path, '/'); + if (s != NULL) *s = '\0'; p += 2; } } @@ -443,7 +444,8 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local) /* Remove '..' from the begin of the filename. */ while (*p == '.') { if (*(++p) == '.') { - *(strrchr(path, '/')) = '\0'; + char *s = strrchr(path, '/'); + if (s != NULL) *s = '\0'; p += 2; } } |