diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C index 3f01384ce7..0add511d14 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C @@ -107,14 +107,15 @@ Foam::Function1::New else if (!coeffs) { // Primitive entry. Coeffs dictionary is optional. - // Use keyword() - not entryName - for compatibility lookup! - coeffs = - &dict.optionalSubDict - ( - eptr->keyword() + "Coeffs", - keyType::LITERAL - ); + const word& kw = + ( + eptr + ? eptr->keyword() // Could be a compatibility lookup + : entryName + ); + + coeffs = &dict.optionalSubDict(kw + "Coeffs", keyType::LITERAL); } diff --git a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1New.C b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1New.C index 925af5b033..33f85c81f2 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1New.C +++ b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1New.C @@ -129,12 +129,14 @@ Foam::PatchFunction1::New // Primitive entry. Coeffs dictionary is optional. // Use keyword() - not entryName - for compatibility lookup! - coeffs = - &dict.optionalSubDict - ( - eptr->keyword() + "Coeffs", - keyType::LITERAL - ); + const word& kw = + ( + eptr + ? eptr->keyword() // Could be a compatibility lookup + : entryName + ); + + coeffs = &dict.optionalSubDict(kw + "Coeffs", keyType::LITERAL); }