Skip to content
Snippets Groups Projects
Commit 24f95d69 authored by Philippe Canal's avatar Philippe Canal
Browse files

In TBuffer::Expand, when shrinking the buffer do not shrink below the size of the

data already accumulated in the buffer (i. no less than the value of TBuffer::Length()).

In TBranch::SetBasketSize, instead of using the hard minimum of 100, use
100 + the length of the branch name (as 100 is too smalli to hold the 
basket's key information for any branch name larger than 30 characters).

This fixes the write past the end of buffer (leading to segfaults)
reported in Savannah:  <http://savannah.cern.ch/bugs/?89645>


git-svn-id: http://root.cern.ch/svn/root/trunk@42425 27541ba8-7e3a-0410-8455-c3a389f83636
parent e2c65514
No related branches found
No related tags found
No related merge requests found
......@@ -204,8 +204,14 @@ void TBuffer::Expand(Int_t newsize, Bool_t copy)
// Expand (or shrink) the I/O buffer to newsize bytes.
// If copy is true (the default), the existing content of the
// buffer is preserved, otherwise the buffer is returned zero-ed out.
//
// In order to avoid losing data, if the current length is greater than
// the requested size, we only shrink down to the current length.
Int_t l = Length();
if ( l > newsize ) {
newsize = l;
}
if ( (fMode&kWrite)!=0 ) {
fBuffer = fReAllocFunc(fBuffer, newsize+kExtraSpace,
copy ? fBufSize+kExtraSpace : 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment