summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-31 14:29:19 +0000
committerrubidium <rubidium@openttd.org>2007-05-31 14:29:19 +0000
commita02417645e4cf1563b01819ac92ab507277b5b56 (patch)
treec2328b6be0f2725cb8ef8571ea5f8dad554f72bc /src
parentefd2fce9a49861cf788a4081192e8ca492944179 (diff)
downloadopenttd-a02417645e4cf1563b01819ac92ab507277b5b56.tar.xz
(svn r9998) -Fix (r9990): possible null pointer dereferences on MorphOS.
Diffstat (limited to 'src')
-rw-r--r--src/fios.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fios.cpp b/src/fios.cpp
index 3d475676e..cdde6e3cd 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -114,11 +114,12 @@ char *FiosBrowseTo(const FiosItem *item)
case FIOS_TYPE_PARENT:
/* Check for possible NULL ptr (not required for UNIXes, but AmigaOS-alikes) */
- if ((s = strrchr(path, PATHSEPCHAR)) != path) {
+ s = strrchr(path, PATHSEPCHAR);
+ if (s != NULL && s != path) {
s[0] = '\0'; // Remove last path separator character, so we can go up one level.
- s = strrchr(path, PATHSEPCHAR);
- if (s != NULL) s[1] = '\0'; // go up a directory
}
+ s = strrchr(path, PATHSEPCHAR);
+ if (s != NULL) s[1] = '\0'; // go up a directory
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
else if ((s = strrchr(path, ':')) != NULL) s[1] = '\0';