Skip to content

Commit ef8e19a

Browse files
committed
Zero-initialize parent_cpstate in analyze_cypher
cypher_parsestate parent_cpstate is declared on the stack in analyze_cypher() and only pstate, graph_name, and params are explicitly set before it is passed to make_cypher_parsestate(). The latter reads parent_cpstate->subquery_where_flag (and other fields) in cypher_parse_node.c, which leaves them with indeterminate values. UBSan flagged the garbage bool (value 8) and aborted the backend. Use MemSet to zero the struct before populating the explicit fields so all remaining members start with a defined value.
1 parent 54e19fa commit ef8e19a

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/backend/parser/cypher_analyze.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ static Query *analyze_cypher(List *stmt, ParseState *parent_pstate,
961961
* convert ParseState into cypher_parsestate temporarily to pass it to
962962
* make_cypher_parsestate()
963963
*/
964+
MemSet(&parent_cpstate, 0, sizeof(parent_cpstate));
964965
parent_cpstate.pstate = *parent_pstate;
965966
parent_cpstate.graph_name = NULL;
966967
parent_cpstate.params = NULL;

0 commit comments

Comments
 (0)