aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/io/natFilePosix.cc
diff options
context:
space:
mode:
authorVladimir Puskas <vpuskas@eunet.yu>2003-01-21 20:45:57 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-01-21 20:45:57 +0000
commit691255fb2ae21560616558637d8f838f3f1322d2 (patch)
tree57a7bb9a11525f22d2e8a098acd05b80ec513c70 /libjava/java/io/natFilePosix.cc
parente8e8c1e5e3c84367e41d7ada5c924574b23350a9 (diff)
downloadgcc-691255fb2ae21560616558637d8f838f3f1322d2.zip
gcc-691255fb2ae21560616558637d8f838f3f1322d2.tar.gz
gcc-691255fb2ae21560616558637d8f838f3f1322d2.tar.bz2
natFileWin32.cc (isAbsolute): Check path length before looking at any characters.
2003-01-21 Vladimir Puskas <vpuskas@eunet.yu> * java/io/natFileWin32.cc (isAbsolute): Check path length before looking at any characters. * java/io/natFilePosix.cc (_stat): Only compute `buf' if it will be used. (isAbsolute): Check path's length as well. From-SVN: r61566
Diffstat (limited to 'libjava/java/io/natFilePosix.cc')
-rw-r--r--libjava/java/io/natFilePosix.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/libjava/java/io/natFilePosix.cc b/libjava/java/io/natFilePosix.cc
index f9fe78e..4946cfc 100644
--- a/libjava/java/io/natFilePosix.cc
+++ b/libjava/java/io/natFilePosix.cc
@@ -1,6 +1,6 @@
// natFile.cc - Native part of File class for POSIX.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
This file is part of libgcj.
@@ -60,14 +60,14 @@ java::io::File::_access (jint query)
jboolean
java::io::File::_stat (jint query)
{
+ if (query == ISHIDDEN)
+ return getName()->charAt(0) == '.';
+
+#ifdef HAVE_STAT
char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
- if (query == ISHIDDEN)
- return (getName()->charAt(0) == '.');
-
-#ifdef HAVE_STAT
struct stat sb;
if (::stat (buf, &sb))
return false;
@@ -131,7 +131,7 @@ java::io::File::getCanonicalPath (void)
jboolean
java::io::File::isAbsolute (void)
{
- return path->charAt(0) == '/';
+ return path->length() > 0 && path->charAt(0) == '/';
}
jobjectArray