FilePermission.java (equals): Use correct index for last character of path.

* java/io/FilePermission.java (equals): Use correct index for
	last character of path.

From-SVN: r70206
This commit is contained in:
Tom Tromey 2003-08-06 19:47:24 +00:00 committed by Tom Tromey
parent 8b82c52809
commit 333384df23
2 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2003-08-06 Tom Tromey <tromey@redhat.com>
* java/io/FilePermission.java (equals): Use correct index for
last character of path.
2003-08-06 Alan Modra <amodra@bigpond.net.au>
* acinclude.m4 (LIBGCJ_CONFIGURE): Remove AC_CANONICAL_BUILD.

View File

@ -144,9 +144,10 @@ public final class FilePermission extends Permission implements Serializable
/* Compare names, taking into account if they refer to a
* directory and one has a separator and the other does not.
*/
if(f1.charAt(f1.length()) == File.separatorChar)
if(f1.length() > 0 && f1.charAt(f1.length() - 1) == File.separatorChar)
{
if(f2.charAt(f2.length()) == File.separatorChar)
if(f2.length() > 0
&& f2.charAt(f2.length() - 1) == File.separatorChar)
{
if(!f2.equals(f1))
return false;
@ -159,7 +160,8 @@ public final class FilePermission extends Permission implements Serializable
}
else
{
if(f2.charAt(f2.length()) == File.separatorChar)
if(f2.length() > 0
&& f2.charAt(f2.length() - 1) == File.separatorChar)
{
if(!f1.equals(f2.substring(0,f2.length()-1)))
return false;