array out-of-bounds in TBranch::GetBasket(Int_t basketnumber)

From: stefan kluth (skluth@mh1.lbl.gov)
Date: Mon Nov 15 1999 - 03:42:59 MET


Hi,

I investigated mysterious crashes I had when reading ROOT files with
purify, since I suspected memory corruption. I found that the array
fBasketRAM in class TBranch is sometimes indexed with numbers < 0. I don't
really understand how this happens, but I did this to get my stuff to run:

In file TREE_Branch.cxx:

...

TBasket* TBranch::GetBasket(Int_t basketnumber) {

...


   fBaskets[basketnumber] = basket;

// protect against fNBasketRAM < 0:
   if( fNBasketRAM >= 0 ) {
     if (fNBasketRAM < kMaxRAM) fBasketRAM[fNBasketRAM] = basketnumber;
   }
   else {
     Warning("GetBasket","fNBasketRAM < 0, shouldn't happen!");
   }

   fNBasketRAM++;
   return basket;



}


I guess I leave it to the experts to find out how this can happen. I would
also like some advice on the fix I did, i.e. if I should expect other
problems now. I work with 2.23/07 on Solaris. 

cheers, Stefan

---Stefan Kluth---------------Lynen Fellow----------------|\--|\-------
-  LBNL, MS 50A 2160       -  phone:  +1 510 495 2376  -  |/  |/      -
-  1 Cyclotron Rd.         -  fax:    +1 510 495 2957  -  |\/\|\/\|'  -
---Berkeley, CA94720, USA-----e-mail: SKluth@lbl.gov------|/\/|/\/|----



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:42 MET