cloudberry icon indicating copy to clipboard operation
cloudberry copied to clipboard

Prevent use after free in flatten_join_alias_var_optimizer function

Open yjhjstz opened this issue 4 months ago • 1 comments

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

Additional Context

CI Skip Instructions


yjhjstz avatar Aug 08 '25 21:08 yjhjstz

ci failed, related https://github.com/apache/cloudberry/issues/1309

yjhjstz avatar Aug 12 '25 19:08 yjhjstz