Skip to content

app_rpt: Use ast_str* for url in res_rpt_http_registraions.c#929

Open
mkmer wants to merge 1 commit intomasterfrom
ast_str-for-url
Open

app_rpt: Use ast_str* for url in res_rpt_http_registraions.c#929
mkmer wants to merge 1 commit intomasterfrom
ast_str-for-url

Conversation

@mkmer
Copy link
Collaborator

@mkmer mkmer commented Feb 5, 2026

Summary by CodeRabbit

Release Notes

  • Refactor
    • Improved memory management in HTTP registration operations with enhanced error handling and resource cleanup to increase stability.

@mkmer mkmer added the code quality Improvments around code quality without functional changes label Feb 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Replaced fixed-size URL buffer with dynamic ast_str allocation in the http_register function. Added null checks and allocation failure handling. Updated URL construction from snprintf to ast_str_set and ensured proper buffer cleanup on all code paths.

Changes

Cohort / File(s) Summary
HTTP Registration URL Management
res/res_rpt_http_registrations.c
Refactored URL buffer handling from fixed-size stack allocation to dynamic ast_str, replacing snprintf with ast_str_set for both port cases. Added null-check after allocation and explicit buffer cleanup on error paths and after curl request completion.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Allan-N
  • InterLinked1
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: replacing a fixed-size URL buffer with dynamic ast_str* in res_rpt_http_registrations.c, which aligns with the detailed summary of changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ast_str-for-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@res/res_rpt_http_registrations.c`:
- Around line 219-240: The code ignores ast_str_set()'s return value which may
be -1 on allocation failure, so after each ast_str_set(...) call verify its
return is non-negative and on failure free resources (ast_free(url),
ast_json_free(data) if allocated) and return -1; ensure you do this for both the
reg->port and else branches before calling ast_str_buffer(url) and curl_post;
refer to the symbols ast_str_create, ast_str_set, ast_str_buffer,
build_request_data, curl_post, ast_json_free, and ast_free to locate and update
the logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Improvments around code quality without functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant