changeset 13182:e87f42d9eca6 draft

(svn r17689) -Fix (r16307): depend could segfault in some case (TrueBrain)
author glx <glx@openttd.org>
date Sun, 04 Oct 2009 12:17:10 +0000
parents 1f3d824fd4d0
children 6395b76151e9
files src/depend/depend.cpp
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/depend/depend.cpp
+++ b/src/depend/depend.cpp
@@ -426,7 +426,8 @@
 		/* 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 @@
 		/* 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;
 			}
 		}