public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch: FYI: fix bad array references
@ 2007-05-02 23:24 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2007-05-02 23:24 UTC (permalink / raw)
  To: GCJ-patches

I'm checking this in on the trunk.

If there is still time I will also merge it to the RH 4.1 branch.

This fixes:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=238755

We weren't checking cases where the index into an array could be
negative.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=238755
	* java/lang/natCharacter.cc (Character::getType): Handle negative
	code points.
	(Character::toLowerCase): Likewise.
	(Character::toUpperCase): Likewise.
	(Character::digit): Likewise.
	(Character::getNumericValue): Likewise.
	(Character::getDirectionality): Likewise.
	(Character::toTitleCase): Likewise.

Index: java/lang/natCharacter.cc
===================================================================
--- java/lang/natCharacter.cc	(revision 124355)
+++ java/lang/natCharacter.cc	(working copy)
@@ -1,5 +1,5 @@
 /* java.lang.Character -- Wrapper class for char, and Unicode subsets
-   Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2002, 2007 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -90,7 +90,7 @@
 java::lang::Character::getType(jint codePoint)
 {
   jint plane = codePoint >> 16;
-  if (plane > 2 && plane != 14)
+  if (plane < 0 || (plane > 2 && plane != 14))
     {
       if (plane > 14 && ((codePoint & 0xffff) < 0xfffe))
         return (jint) PRIVATE_TYPE;
@@ -112,7 +112,7 @@
 java::lang::Character::toLowerCase(jint codePoint)
 {
   jint plane = codePoint >> 16;
-  if (plane > 2 && plane != 14)
+  if (plane < 0 || (plane > 2 && plane != 14))
     return codePoint;
   return (lower[plane][readCodePoint(codePoint) >> 7]) + codePoint;
 }
@@ -127,7 +127,7 @@
 java::lang::Character::toUpperCase(jint codePoint)
 {
   jint plane = codePoint >> 16;
-  if (plane > 2 && plane != 14)
+  if (plane < 0 || (plane > 2 && plane != 14))
     return codePoint;
   return (upper[plane][readCodePoint(codePoint) >> 7]) + codePoint;
 }
@@ -147,7 +147,7 @@
 {
   // As of Unicode 4.0.0 no characters outside of plane 0 have titlecase
   // mappings that are different from their uppercase mapping.
-  if (codePoint < 0x10000)
+  if (codePoint >= 0 && codePoint < 0x10000)
     return toTitleCase((jchar)codePoint);
   return toUpperCase(codePoint);
 }
@@ -177,7 +177,7 @@
     return (jint) -1;
 
   jint plane = codePoint >> 16;
-  if (plane > 2 && plane != 14)
+  if (plane < 0 || (plane > 2 && plane != 14))
     return UNASSIGNED_DIGIT;
 
   jchar attr = readCodePoint(codePoint);
@@ -207,7 +207,7 @@
 java::lang::Character::getNumericValue(jint codePoint)
 {
   jint plane = codePoint >> 16;
-  if (plane > 2 && plane != 14)
+  if (plane < 0 || (plane > 2 && plane != 14))
     return UNASSIGNED_NUMERIC_VALUE;
   jshort num = numValue[plane][readCodePoint(codePoint) >> 7];
   if (num <= -3)
@@ -225,7 +225,7 @@
 java::lang::Character::getDirectionality(jint codePoint)
 {
   jint plane = codePoint >> 16;
-  if (plane > 2 && plane != 14)
+  if (plane < 0 || (plane > 2 && plane != 14))
     {
       if (plane > 14 && ((codePoint & 0xffff) < 0xfffe))
         return (jint) PRIVATE_DIRECTION;
@@ -233,5 +233,3 @@
     }
   return direction[plane][readCodePoint(codePoint) >> 7];
 }
-
-

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-05-02 23:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-02 23:24 Patch: FYI: fix bad array references Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).