Corrections to avoid reading outside clusters array
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 15 May 2004 00:30:39 +0000 (00:30 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 15 May 2004 00:30:39 +0000 (00:30 +0000)
TPC/AliTPCtrackerMI.cxx

index cb1bdb05a4994a9a0e24d78bf18bc210508e8bcc..63f315944222a9c3dbb1f20c6bc54f0741c74d48 100644 (file)
@@ -1414,23 +1414,34 @@ AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
 
   const AliTPCRow * tpcrow=0;
   AliTPCclusterMI * clrow =0;
+
   if (sec<fkNIS*2){
     tpcrow = &(fInnerSec[sec%fkNIS][row]);
-    if (sec<fkNIS) 
+    if (tpcrow==0) return 0;
+
+    if (sec<fkNIS) {
+      if (tpcrow->fN1<=ncl) return 0;
       clrow = tpcrow->fClusters1;
-    else
+    }
+    else {
+      if (tpcrow->fN2<=ncl) return 0;
       clrow = tpcrow->fClusters2;
+    }
   }
-  else{
+  else {
     tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
-    if (sec-2*fkNIS<fkNOS)
+    if (tpcrow==0) return 0;
+
+    if (sec-2*fkNIS<fkNOS) {
+      if (tpcrow->fN1<=ncl) return 0;
       clrow = tpcrow->fClusters1;
-    else
+    }
+    else {
+      if (tpcrow->fN2<=ncl) return 0;
       clrow = tpcrow->fClusters2;
+    }
   }
-  if (tpcrow==0) return 0;
-  if (tpcrow->GetN()<=ncl) return 0;
-  //  return (AliTPCclusterMI*)(*tpcrow)[ncl];      
+
   return &(clrow[ncl]);      
   
 }