cloudberry
cloudberry copied to clipboard
Prevent use after free in flatten_join_alias_var_optimizer function
This patch prevents several use after free bugs present in flatten_join_alias_var_optimizer. Specifically, the function uses flatten_join_alias_vars function multiple times, and assumes that the original node can be freed immediately after. This is not always the case since under some circumstances flatten_join_alias_vars does not modify its input and simply passes it through without copying. This patch adds conditions to check if the original node can safely be freed, preventing use after free.
Fixes #ISSUE_Number
What does this PR do?
Type of Change
- [ ] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change (fix or feature with breaking changes)
- [ ] Documentation update
Breaking Changes
Test Plan
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Passed
make installcheck - [ ] Passed
make -C src/test installcheck-cbdb-parallel
Impact
Performance:
User-facing changes:
Dependencies:
Checklist
- [ ] Followed contribution guide
- [ ] Added/updated documentation
- [ ] Reviewed code for security implications
- [ ] Requested review from cloudberry committers
Additional Context
CI Skip Instructions
ci failed, related https://github.com/apache/cloudberry/issues/1309