Skip to content

Fix reference leaks in parser logger callback - #485

Merged
ObserverOfTime merged 1 commit into
tree-sitter:masterfrom
A-S-Manoj:fix/482-log-callback-refleak
Aug 2, 2026
Merged

Fix reference leaks in parser logger callback#485
ObserverOfTime merged 1 commit into
tree-sitter:masterfrom
A-S-Manoj:fix/482-log-callback-refleak

Conversation

@A-S-Manoj

Copy link
Copy Markdown
Contributor

log_callback() in tree_sitter/binding/parser.c leaked both the
LogType enum object returned by the enum constructor and the return
value of the Python logger callback. Neither reference was released.

This adds a NULL check on the enum construction and properly
decrefs both the enum and the callback result.

Fixes #482

@A-S-Manoj

Copy link
Copy Markdown
Contributor Author

Ran the full test suite locally using pytest tests/ all 60 tests pass. Also checked out master without my change and the failing tests pass there too on my machine(Python 3.14, Fedora), appears to be platform specific and unrelated to this diff.

@ObserverOfTime

Copy link
Copy Markdown
Member

The test issue is fixed. Please rebase.

log_callback() leaked both the LogType enum object and the Python callback's return value. Both are now properly released.  Fixes tree-sitter#482
@A-S-Manoj
A-S-Manoj force-pushed the fix/482-log-callback-refleak branch from e0db811 to 6911ec2 Compare July 28, 2026 13:43
@ObserverOfTime
ObserverOfTime merged commit 450d361 into tree-sitter:master Aug 2, 2026
29 checks passed
@A-S-Manoj
A-S-Manoj deleted the fix/482-log-callback-refleak branch August 2, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reference leaks in parser logger callback

2 participants