This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] natString.cc: Some fixes for bounds checking arithmetic.


Ralph Loader wrote:
libgcj contains many places where checking of array index arguments
passed to methods is done incorrectly.

The attached patch fixes those in natString.cc that it is not difficult
to write test cases for.

There are many other instances of incorrect bounds checking that would
require a 64 bit machine with gigabytes of memory (which I don't have),
in order to write proper test cases.

I was wondering about a similar thing in kaffe, and it may be saner to write the array index argument checking code once in a final class in Java and/or a static inline method in C++/function in C and let the compiler do the inlining magic.


That way, you'd only need to get the test right once. And having a

public final class ArrayUtils {
public static final void checkBounds(int off, int array_len, int count) throws IndexOutOfBoundException {
if (off < 0 || count < 0 || .... ) throw new IndexOutOfBoundsException(...);
}


and static inline void checkArrayBounds(int off, int array_len, int count) accordingly.

what do you think?

cheers,
dalibor topic




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]