Skip to content

Commit e9ef30b

Browse files
authored
Zero-initialize parent_cpstate in analyze_cypher (#2423)
cypher_parsestate parent_cpstate is declared on the stack in analyze_cypher() and only pstate is 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 pstate so all remaining members start with a defined value. Co-authored-by: Hari Krishna Sunder <12418230+hari90@users.noreply.github.com>
1 parent 54e19fa commit e9ef30b

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/backend/parser/cypher_analyze.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,9 +961,8 @@ 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;
965-
parent_cpstate.graph_name = NULL;
966-
parent_cpstate.params = NULL;
967966

968967
cpstate = make_cypher_parsestate(&parent_cpstate);
969968

0 commit comments

Comments
 (0)