[kaffe] String problem / NullPointerException in KJC

Helmer Krämer hkraemer at freenet.de
Thu Jul 3 09:08:01 PDT 2003


On Wed, 2 Jul 2003 21:08:05 +0100
Guilhem Lavaux <guilhem.lavaux at free.fr> wrote:

Hi,

> I then wondered if this may be caused by the original Boyer-Moore algorithm 
> implemented in Kaffe and so I tried to shutdown it: the problem disappeared. 
> Looking at the code I am a little surprised of one statement which can cause 
> an "overread" of a string buffer:
> 
>         k= n - m+1;
>        ^^^^^^^^^^^^^^
>         for ( i=offset; i <= k; ) {
>           if ( memcmp( &a[i], p, m2) == 0 )
>                 return i;
>           i += bs[ (unsigned char)a[i+m] ];
> 					^^^^^^^^^^^ 
>        }
> 
> It seems that it is possible the algorithm wants to fetch a[n+1] and this may 
> cause the NullPointerException. Changing i<=k in i<k solves the problem for 
> KJC although I do know if it is the right to do because I am not really aware 
> of the Boyer-Moore algorithm.
> 
> Any comments ? I included the log of KJC during the compilation of the core 
> classes.

i think even i<k is still wrong ;) n Is the length of the string
and m is the length of the pattern, so the largest possible start
index of the pattern is n-m-1. Therefore it should be n-m-1 and
<=k or n-m and <k, shouldn't it?

Greetings,
Helmer




More information about the kaffe mailing list