Skip to content

Commit fcdb35c

Browse files
committed
Fix transformJsonBehavior
Commit 1a36bc9 conained some logic that was a little opaque and could have involved a NULL dereference, as complained about by Coverity. Make the logic more transparent and in doing so avoid the NULL dereference.
1 parent cd4868a commit fcdb35c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/backend/parser/parse_expr.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,13 +4072,15 @@ static JsonBehavior *
40724072
transformJsonBehavior(ParseState *pstate, JsonBehavior *behavior,
40734073
JsonBehaviorType default_behavior)
40744074
{
4075-
JsonBehaviorType behavior_type;
4076-
Node *default_expr;
4077-
4078-
behavior_type = behavior ? behavior->btype : default_behavior;
4079-
default_expr = behavior_type != JSON_BEHAVIOR_DEFAULT ? NULL :
4080-
transformExprRecurse(pstate, behavior->default_expr);
4075+
JsonBehaviorType behavior_type = default_behavior;
4076+
Node *default_expr = NULL;
40814077

4078+
if (behavior)
4079+
{
4080+
behavior_type = behavior->btype;
4081+
if (behavior_type == JSON_BEHAVIOR_DEFAULT)
4082+
default_expr = transformExprRecurse(pstate, behavior->default_expr);
4083+
}
40824084
return makeJsonBehavior(behavior_type, default_expr);
40834085
}
40844086

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy