2 protections added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Jan 2004 17:12:45 +0000 (17:12 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Jan 2004 17:12:45 +0000 (17:12 +0000)
Flugg/FGeometryInit.cxx

index 6501004..9fbcd9c 100644 (file)
@@ -807,9 +807,23 @@ void FGeometryInit::PrintMagneticField(std::ostream& os) {
 
 int FGeometryInit::CurrentVolID(int ir, int& copyNo)
 {
+    if (ir == 0) 
+    {
+       copyNo = -1;
+       return -1;
+    }
+    
     G4PhysicalVolumeStore * pVolStore = G4PhysicalVolumeStore::GetInstance();
-    G4VPhysicalVolume * physicalvol = (*pVolStore)[ir- 1];
-    copyNo =  physicalvol->GetCopyNo();
+    G4VPhysicalVolume   * physicalvol = (*pVolStore)[ir- 1];
+    
+    if (physicalvol) {
+       copyNo =  physicalvol->GetCopyNo();
+    } else {
+       copyNo = -1;
+       return -1;
+    }
+    
+    
     int id = fVolIdVolumeMap[physicalvol];
     return id;
 }