From 024d22cb640638be636dfaf4d907679638f4efd6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 26 Nov 2020 01:53:15 +0100 Subject: [PATCH] BUG: missing nullptr check in Function1/PatchFunction1 fallback logic --- .../functions/Function1/Function1/Function1New.C | 15 ++++++++------- .../PatchFunction1/PatchFunction1New.C | 14 ++++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) 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); }