mirror of
https://github.com/postgres/postgres.git
synced 2025-05-23 00:02:38 -04:00
Fix transformJsonBehavior
Commit 1a36bc9dba8 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.
This commit is contained in:
parent
cd4868a570
commit
fcdb35c32a
@ -4072,13 +4072,15 @@ static JsonBehavior *
|
|||||||
transformJsonBehavior(ParseState *pstate, JsonBehavior *behavior,
|
transformJsonBehavior(ParseState *pstate, JsonBehavior *behavior,
|
||||||
JsonBehaviorType default_behavior)
|
JsonBehaviorType default_behavior)
|
||||||
{
|
{
|
||||||
JsonBehaviorType behavior_type;
|
JsonBehaviorType behavior_type = default_behavior;
|
||||||
Node *default_expr;
|
Node *default_expr = NULL;
|
||||||
|
|
||||||
behavior_type = behavior ? behavior->btype : default_behavior;
|
|
||||||
default_expr = behavior_type != JSON_BEHAVIOR_DEFAULT ? NULL :
|
|
||||||
transformExprRecurse(pstate, behavior->default_expr);
|
|
||||||
|
|
||||||
|
if (behavior)
|
||||||
|
{
|
||||||
|
behavior_type = behavior->btype;
|
||||||
|
if (behavior_type == JSON_BEHAVIOR_DEFAULT)
|
||||||
|
default_expr = transformExprRecurse(pstate, behavior->default_expr);
|
||||||
|
}
|
||||||
return makeJsonBehavior(behavior_type, default_expr);
|
return makeJsonBehavior(behavior_type, default_expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user