]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Set of protections and bug fixes
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Jan 2009 13:06:27 +0000 (13:06 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Jan 2009 13:06:27 +0000 (13:06 +0000)
STEER/AliRunTag.cxx

index 13b2742cd7742f241323ca68826d895a9c036e54..dae219139c9d2f2e33abb8d81c654b53bb201fe3 100644 (file)
@@ -94,13 +94,13 @@ fEventSpecies(NULL)
   if (fQALength == 0 ) 
     fQA = NULL ; 
   else {
-    fQA = new ULong_t(fQALength) ; 
+    fQA = new ULong_t[fQALength] ; 
     memcpy(fQA, tag.fQA, fQALength*sizeof(ULong_t)) ;
   }
   if (fESLength == 0 ) 
     fEventSpecies = NULL ; 
   else {
-    fEventSpecies = new Bool_t(fESLength) ; 
+    fEventSpecies = new Bool_t[fESLength] ; 
     memcpy(fEventSpecies, tag.fEventSpecies, fESLength*sizeof(Bool_t)) ;
   }
 }
@@ -132,7 +132,7 @@ AliRunTag& AliRunTag::operator = (const AliRunTag& tag) {
     if (fQALength == 0 ) 
       fQA = NULL ; 
     else {
-      fQA = new ULong_t(fQALength) ; 
+      fQA = new ULong_t[fQALength] ; 
       memcpy(fQA, tag.fQA, fQALength*sizeof(ULong_t)) ;
     }
     fESLength                 = tag.fESLength ; 
@@ -141,6 +141,7 @@ AliRunTag& AliRunTag::operator = (const AliRunTag& tag) {
     if (fESLength == 0 ) 
       fEventSpecies = NULL ; 
     else {
+      fEventSpecies = new Bool_t[fESLength] ; 
       memcpy(fEventSpecies, tag.fEventSpecies, fESLength*sizeof(Bool_t)) ;
     }
   }
@@ -171,21 +172,25 @@ void AliRunTag::CopyStandardContent(AliRunTag *oldtag) {
 //___________________________________________________________________________
 void AliRunTag::SetQA(ULong_t * qa, Int_t qalength) {
   //Setter for the qa bits 
-  fQALength = qalength ; 
-  if (fQA) 
-    delete [] fQA ; 
-  fQA = new ULong_t(qalength) ; 
-  memcpy(fQA, qa, qalength*sizeof(ULong_t)) ;
+  if (qa && qalength > 0) {
+    fQALength = qalength ; 
+    if (fQA) 
+      delete [] fQA ; 
+    fQA = new ULong_t[qalength] ; 
+    memcpy(fQA, qa, qalength*sizeof(ULong_t)) ;
+  }
 }
 
 //___________________________________________________________________________
 void AliRunTag::SetEventSpecies(Bool_t * es, Int_t eslength) {
   //setter for the eventspecices 
-  fESLength = eslength ; 
-  if (fEventSpecies) 
-    delete [] fEventSpecies ; 
-  fEventSpecies = new Bool_t(eslength) ;
-  memcpy(fEventSpecies, es, eslength*sizeof(Bool_t)) ; 
+  if (es && eslength >0 ) {
+    fESLength = eslength ; 
+    if (fEventSpecies) 
+      delete [] fEventSpecies ; 
+    fEventSpecies = new Bool_t[eslength] ;
+    memcpy(fEventSpecies, es, eslength*sizeof(Bool_t)) ; 
+  }
 }