Skip to content

Commit bb5d8ef

Browse files
authored
fix: temporary fix UB on historyBaseCollection (#3886)
Segmentation fault fix when we entered a wrong objectPath to the PackCollection in getTargetObject().
1 parent e41a700 commit bb5d8ef

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/coreComponents/fileIO/timeHistory/HistoryCollectionBase.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
*/
1515

1616
#include "HistoryCollectionBase.hpp"
17+
#include "common/format/Format.hpp"
18+
#include "common/logger/Logger.hpp"
19+
#include "fileIO/timeHistory/PackCollection.hpp"
20+
#include <stdexcept>
1721

1822
namespace geos
1923
{
@@ -171,6 +175,11 @@ dataRepository::Group const * HistoryCollectionBase::getTargetObject( DomainPart
171175

172176
if( targetTokens[2]== MeshLevel::groupStructKeys::elemManagerString() )
173177
{
178+
179+
GEOS_THROW_IF( targetTokens.size() <= 4,
180+
GEOS_FMT( " Object Path '{}' does not target any element sub region",
181+
objectPath ),
182+
std::runtime_error );
174183
ElementRegionManager const & elemRegionManager = meshLevel.getElemManager();
175184
string const elemRegionName = targetTokens[3];
176185
ElementRegionBase const & elemRegion = elemRegionManager.getRegion( elemRegionName );

0 commit comments

Comments
 (0)