using safe string oparations, pointer checks
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 23 Feb 2011 10:50:54 +0000 (10:50 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 23 Feb 2011 10:50:54 +0000 (10:50 +0000)
HLT/TPCLib/AliHLTTPCGlobalMerger.cxx
HLT/TPCLib/AliHLTTPCInterMerger.cxx
HLT/TPCLib/AliHLTTPCTrackMerger.cxx

index 456ac32..577b70e 100644 (file)
@@ -235,8 +235,9 @@ void AliHLTTPCGlobalMerger::SlowMerge(const Char_t *path)
        <<AliHLTTPCLog::kDec<<"Merged Tracks: "<<tout->GetNTracks()<<" at:"
        <<angle<<ENDLOG;
     }
-  Char_t fname[1024];
-  sprintf(fname,"%s/merge_parameters.root",path);
+  const int namelen=1024;
+  Char_t fname[namelen];
+  snprintf(fname,namelen,"%s/merge_parameters.root",path);
   WriteNtuple(fname,ntuple);
 }
 
index f4bd29a..7e1cc40 100644 (file)
@@ -64,7 +64,7 @@ void AliHLTTPCInterMerger::SlowMerge(){
   AliHLTTPCTrack *tr[2];
   Bool_t merge = kTRUE;
   for(Int_t in=0;in<kNIn;in++)
-    tracks->GetCheckedTrack(in)->CalculateHelix();
+    if (tracks->GetCheckedTrack(in)) tracks->GetCheckedTrack(in)->CalculateHelix();
   while(merge){
     Int_t inmin=-1,outmin=-1;
     Double_t min=10;
@@ -105,8 +105,9 @@ void AliHLTTPCInterMerger::SlowMerge(){
   LOG(AliHLTTPCLog::kInformational,"AliHLTTPCInterMerger::SlowMerge","Result")
   <<AliHLTTPCLog::kDec<<"Merged Tracks: "<<tracks->GetNTracks()-kNIn<<ENDLOG;
 
-  char name[256];
-  sprintf(name,"ntuple_i_%d.root",fPatch);
+  const int namelen=256;
+  char name[namelen];
+  snprintf(name,namelen,"ntuple_i_%d.root",fPatch);
   WriteNtuple(name,ntuple);
 }
 
index 7c4fb62..2655c01 100644 (file)
@@ -144,10 +144,11 @@ void AliHLTTPCTrackMerger::SlowMerge(AliHLTTPCTrackArray *mergedtrack,AliHLTTPCT
   LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTrackMerger::SlowMerge","Result")
   <<AliHLTTPCLog::kDec<<"Merged Tracks: "
   <<mergedtrack->GetNTracks()-kNMerged<<ENDLOG;
-  char name[256] = "ntuple_t.root";
+  const int namelen=256;
+  char name[namelen] = "ntuple_t.root";
   for(Int_t i=0;i<4;i++)
     if(tracksin==GetInTracks(i))
-      sprintf(name,"ntuple_t_%d.root",i);
+      snprintf(name,namelen,"ntuple_t_%d.root",i);
   WriteNtuple(name,ntuple);
 }