Skip to content

Commit

Permalink
Fix memory leak in tracetools::get_symbol()
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
  • Loading branch information
christophebedard committed Feb 15, 2023
1 parent 01b1924 commit 93bbc61
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion rclcpp/include/rclcpp/any_service_callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ class AnyServiceCallback
#ifndef TRACETOOLS_DISABLED
std::visit(
[this](auto && arg) {
char * symbol = tracetools::get_symbol(arg);
TRACEPOINT(
rclcpp_callback_register,
static_cast<const void *>(this),
tracetools::get_symbol(arg));
symbol);
std::free(symbol);
}, callback_);
#endif // TRACETOOLS_DISABLED
}
Expand Down
4 changes: 3 additions & 1 deletion rclcpp/include/rclcpp/any_subscription_callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,12 @@ class AnySubscriptionCallback
#ifndef TRACETOOLS_DISABLED
std::visit(
[this](auto && callback) {
char * symbol = tracetools::get_symbol(callback);;
TRACEPOINT(
rclcpp_callback_register,
static_cast<const void *>(this),
tracetools::get_symbol(callback));
symbol);
std::free(symbol);
}, callback_variant_);
#endif // TRACETOOLS_DISABLED
}
Expand Down
4 changes: 3 additions & 1 deletion rclcpp/include/rclcpp/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ class GenericTimer : public TimerBase
rclcpp_timer_callback_added,
static_cast<const void *>(get_timer_handle().get()),
reinterpret_cast<const void *>(&callback_));
char * symbol = tracetools::get_symbol(callback_);
TRACEPOINT(
rclcpp_callback_register,
reinterpret_cast<const void *>(&callback_),
tracetools::get_symbol(callback_));
symbol);
std::free(symbol);
}

/// Default destructor.
Expand Down

0 comments on commit 93bbc61

Please sign in to comment.