Repository navigation
Conversation
Release all libxml objects on exit paths. Enforce the configured link limit before adding a new handle.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The cleanup paths and link-counting logic are complete and consistent with libxml ownership requirements.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes resource leaks and enforces the crawler’s per-page link limit correctly.
Changes:
- Frees libxml documents and URL allocations on all exit paths.
- Handles XPath context allocation failure.
- Prevents exceeding
max_link_per_page.
| File | Description |
|---|---|
docs/examples/crawler.c |
Corrects link parsing cleanup and limit enforcement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change?
follow_links()owns the libxml document returned byhtmlReadMemory()and eachxmlCharURL returned byxmlNodeListGetString()orxmlBuildURI(). The document was not released on several returns or after a successful scan, and short links and the link-limit exit could leave the current URL allocated.The existing post-increment limit check also admitted one more HTTP(S) link than
max_link_per_page. With the default limit of 5, the function could add 6 handles.What does this change do?
continueand limitbreakpaths.Testing
perl scripts/checksrc.pl docs/examples/crawler.ccrawler.cwith GCC using-Wall -Wextra -WerrorAI-assisted discovery disclosure
This issue was initially identified with AI-assisted tooling. The patch was then manually reviewed and validated with the tests described above.