Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix queryktharr() return value/behaviour. #4186

Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Src/Base/AMReX_ParmParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ getToken (const char*& str, std::string& ostr, int& num_linefeeds)
//
// Return the index of the n'th occurrence of a parameter name,
// except if n==-1, return the index of the last occurrence.
// Return 0 if the specified occurrence does not exist.
// Return nullptr if the specified occurrence does not exist.
//
std::vector<std::string> const*
ppindex (const ParmParse::Table& table, int n, const std::string& name)
Expand All @@ -365,7 +365,10 @@ ppindex (const ParmParse::Table& table, int n, const std::string& name)
if (n == ParmParse::LAST) {
return &(found->second.m_vals.back());
} else {
return &(found->second.m_vals[n]);
if(found->second.m_vals.size() < (std::size_t)n + 1) {
return nullptr;
}
return &(found->second.m_vals[n]);
philip-blakely marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -642,7 +645,7 @@ squeryval (const ParmParse::Table& table,
int occurrence)
{
//
// Get last occurrence of name in table.
// Get specified occurrence of name in table.
//
auto const* def = ppindex(table, occurrence, name);
if ( def == nullptr )
Expand Down
Loading