You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In several parts of the c++ code, a raw pointer is used as the result of certain functions. For example, in GateUniqueVolumeID.cpp you have
G4AffineTransform *GateUniqueVolumeID::GetLocalToWorldTransform(size_t depth) {
{... irrelevant ...}
auto &rotation = fVolumeDepthID[depth].fRotation;
auto &translation = fVolumeDepthID[depth].fTranslation;
auto t = newG4AffineTransform(rotation, translation);
return t;
}
This is allocating a new G4AffineTransform object on the heap with new. This can lead to a memory leak if the memory is not properly released.
To fix this issue, you should consider using smart pointers or containers that manage memory for you, such as std::unique_ptr or std::shared_ptr. This will ensure that the memory is released when it is no longer needed.
Here is an example of how you can modify the line to use std::unique_ptr:
std::unique_ptr<G4AffineTransform> GateUniqueVolumeID::GetLocalToWorldTransform(size_t depth) {
{... irrelevant ...}
auto &rotation = fVolumeDepthID[depth].fRotation;
auto &translation = fVolumeDepthID[depth].fTranslation;
auto t = std::make_unique<G4AffineTransform>(rotation, translation); // Critical changereturn t;
}
Issue generated with Snyk
The text was updated successfully, but these errors were encountered:
In several parts of the c++ code, a raw pointer is used as the result of certain functions. For example, in GateUniqueVolumeID.cpp you have
This is allocating a new G4AffineTransform object on the heap with new. This can lead to a memory leak if the memory is not properly released.
To fix this issue, you should consider using smart pointers or containers that manage memory for you, such as
std::unique_ptr
orstd::shared_ptr
. This will ensure that the memory is released when it is no longer needed.Here is an example of how you can modify the line to use std::unique_ptr:
Issue generated with Snyk
The text was updated successfully, but these errors were encountered: