Content-Length: 282927 | pFad | https://github.com/postgrespro/postgres/commit/fcdb35c32ac70a113c134a66daf9ba28523ff32b

35 Fix transformJsonBehavior · postgrespro/postgres@fcdb35c · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/postgrespro/postgres/commit/fcdb35c32ac70a113c134a66daf9ba28523ff32b

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy