]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding NULL pointer protection and safe string operation
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Feb 2011 22:40:35 +0000 (22:40 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Feb 2011 22:40:35 +0000 (22:40 +0000)
HLT/BASE/AliHLTComponent.cxx

index e2cb3897b002be3096366019cf3463414eac84df..b6deff040ca0f4fe4f13266d6190a458e89e15fd 100644 (file)
@@ -696,7 +696,7 @@ void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char o
   // see header file for function documentation
   memset( output, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 );
   strncat( output, type.fOrigin, kAliHLTComponentDataTypefOriginSize );
-  strcat( output, ":" );
+  strncat( output, ":", 1 );
   strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
 }
 
@@ -1702,10 +1702,14 @@ int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
     fEventDoneData = newEDD;
     fEventDoneDataSize = newSize;
   }
-  else {
+  else if (fEventDoneData) {
     memcpy( reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize, edd.fData, edd.fDataSize );
     fEventDoneData->fDataSize += edd.fDataSize;
   }
+  else {
+    HLTError("internal mismatch, fEventDoneData=%d but buffer is NULL", fEventDoneDataSize);
+    iResult=-EFAULT;
+  }
   return iResult;
 }