]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
minor memory leak fixed, using safe string operations
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 5 Apr 2011 06:58:49 +0000 (06:58 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 5 Apr 2011 06:58:49 +0000 (06:58 +0000)
HLT/trigger/AliHLTTriggerBarrelGeomMultiplicity.cxx
HLT/trigger/AliHLTTriggerBarrelGeomMultiplicity.h

index ecc46df0f148a7b6b84074f6501a791b66ce256e..f0b5be8e19cb7c5948074ca99b3ebd4290c20302 100644 (file)
@@ -219,6 +219,10 @@ int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
   // first configure the default
   int iResult=0;
 
+  // Matthias 05.04.2011 code audit
+  // looks like somebody has to commission this component
+  HLTWarning("this component is not tested and needs most likely a major revision!");
+
   if (iResult>=0 && argc>0)
     iResult=ConfigureFromArgumentString(argc, argv);
 
@@ -234,6 +238,8 @@ int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
 int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
  {
   // see header file for class documentation
+   if (fTriggerName) delete fTriggerName;
+   fTriggerName=NULL;
   return 0;
 }
 
@@ -393,10 +399,12 @@ int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, con
 
   if (argument.CompareTo("-triggername")==0) 
     {
-      if (++i>=argc) return -EPROTO;
-      
-      fTriggerName = new char[128];
-      sprintf(fTriggerName, "%s", argv[i]);
+      if (++i>=argc || argv[i]==NULL) return -EPROTO;
+
+      int namelen=strlen(argv[i])+1;
+      fTriggerName = new char[namelen];
+      if (!fTriggerName) return -ENOMEM;
+      snprintf(fTriggerName, namelen, "%s", argv[i]);
       
       fOCDBEntry = fTriggerName;
 
index e620eaa9f8ac62271668a865b507777f1ee4b1c3..8a3f1fdf810838004355f02bef6da06fde4bba0b 100644 (file)
@@ -1,3 +1,5 @@
+//-*- Mode: C++ -*-
+// $Id$
 #ifndef ALIHLTTRIGGERBARRELGEOMMULTIPLICITY_H
 #define ALIHLTTRIGGERBARRELGEOMMULTIPLICITY_H
 //* This file is property of and copyright by the ALICE HLT Project        *