-
Notifications
You must be signed in to change notification settings - Fork 79
Support creating node with ros args #1166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,8 @@ | |||||||
| #include <rcl_yaml_param_parser/parser.h> | ||||||||
| #include <rcl_yaml_param_parser/types.h> | ||||||||
|
|
||||||||
| #include <rcpputils/scope_exit.hpp> | ||||||||
| // NOLINTNEXTLINE | ||||||||
| #include <string> | ||||||||
|
|
||||||||
| #include "macros.h" | ||||||||
|
|
@@ -180,10 +182,34 @@ Napi::Value CreateNode(const Napi::CallbackInfo& info) { | |||||||
| rcl_context_t* context = | ||||||||
| reinterpret_cast<rcl_context_t*>(context_handle->ptr()); | ||||||||
|
|
||||||||
| rcl_node_t* node = reinterpret_cast<rcl_node_t*>(malloc(sizeof(rcl_node_t))); | ||||||||
| Napi::Array jsArgv = info[3].As<Napi::Array>(); | ||||||||
|
||||||||
| Napi::Array jsArgv = info[3].As<Napi::Array>(); | |
| Napi::Object optionsObject = info[3].As<Napi::Object>(); | |
| Napi::Array jsArgv = info[4].As<Napi::Array>(); |
Copilot
AI
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argument indices no longer align with the JS wrapper signature (which also takes options). You should extract options from info[3], then shift jsArgv to info[4] and useGlobalArguments to info[5], with proper type checks and info.Length() validation.
Copilot
AI
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argv buffer allocated by AbstractArgsFromNapiArray is not freed on the successful path, resulting in a memory leak. Call FreeArgs(argv, argc) after rcl_node_init (or use a scope guard) to release the allocated memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using a scope exit guard (e.g.
RCPPUTILS_SCOPE_EXIT) forFreeArgsso thatargvis always freed even ifrcl_initorrcl_logging_configurethrow an exception before reaching this line.