Menu

#15 bug in StringBuffer v.0.8.12

closed-fixed
nobody
None
5
2004-11-18
2004-08-19
ysun
No

Someone else ever submitted bugs in StringBuffer.
However, in the latest release v.0.8.12, I found a bug
in function StringBuffer::prepend():

void StringBuffer::prepend( const char_t* value ){
int_t sl = stringLength(value);
if ( len+sl+1 > bufferLength )
growBuffer ( len+sl+1 );

//move buffer up
// here is the bug in for statement, len+1 is out of
the array
// boundary
//for ( int_t i=len+1;i>=0;i-- )
for ( int_t i=len;i>=0;i-- )
buffer[i+sl] = buffer[i];

len += sl;

for ( int_t i=0;i<sl;i++ )
buffer[i] = value[i];
}

I didn't check the version in cvs, a "bad gateway"
error occurs while browsing cvs tree.

Discussion

  • David S. Rushby

    David S. Rushby - 2004-08-21

    Logged In: YES
    user_id=414645

    Thank you for the report.

    I started to apply that single fix, but in scrutinizing the
    StringBuffer code, found a few other bugs in
    StringBuffer.cpp, mostly of the same off-by-one nature. I
    ended up changing StringBuffer more extensively than I had
    expected, fixing several bugs and also improving performance.

    I've just checked these changes into CVS, and I'd appreciate
    your feedback. In particular, look at util/StringBuffer.h,
    util/StringBuffer.cpp, and also
    /CLConfig.h:LUCENE_DEFAULT_TOKEN_BUFFER_SIZE (for some
    performance notes).

    Since I've made several other important changes in CVS since
    the most recent packaged release, I suggest you do a CVS
    checkout rather than grabbing only these particular files.
    Remember that the StringBuffer-related checkins might not
    appear in Sourceforge's anonymous CVS for several hours.

     
  • David S. Rushby

    David S. Rushby - 2004-11-01

    Logged In: YES
    user_id=414645

    I worked over StringBuffer.cpp in late Aug 2004 and removed
    all the bugs I encountered. It's my opinion that the bug(s)
    reported here are resolved.

     
  • Ben van Klinken

    Ben van Klinken - 2004-11-18
    • status: open --> closed-fixed
     
  • Ben van Klinken

    Ben van Klinken - 2004-11-18

    Logged In: YES
    user_id=763834

    resolved, but uses different code

     

Log in to post a comment.

MongoDB Logo MongoDB