Skip to content
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

Check allocator validity in some rcl_logging functions #116

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rcl_logging_interface/src/logging_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rcl_logging_get_logging_directory(rcutils_allocator_t allocator, char ** directo
RCUTILS_SET_ERROR_MSG("directory argument must not be null");
return RCL_LOGGING_RET_INVALID_ARGUMENT;
}
RCUTILS_CHECK_ALLOCATOR(&allocator, return RCL_LOGGING_RET_INVALID_ARGUMENT);
if (NULL != *directory) {
RCUTILS_SET_ERROR_MSG("directory argument must point to null");
return RCL_LOGGING_RET_INVALID_ARGUMENT;
Expand Down
2 changes: 2 additions & 0 deletions rcl_logging_spdlog/src/rcl_logging_spdlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ rcl_logging_ret_t rcl_logging_external_initialize(
const char * config_file,
rcutils_allocator_t allocator)
{
RCUTILS_CHECK_ALLOCATOR(&allocator, return RCL_LOGGING_RET_INVALID_ARGUMENT);

std::lock_guard<std::mutex> lk(g_logger_mutex);
// It is possible for this to get called more than once in a process (some of
// the tests do this implicitly by calling rclcpp::init more than once).
Expand Down
2 changes: 1 addition & 1 deletion rcl_logging_spdlog/test/test_logging_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ TEST_F(LoggingTest, init_invalid)
rcl_logging_external_initialize("anything", nullptr, bad_allocator));
rcutils_reset_error();
EXPECT_EQ(
RCL_LOGGING_RET_ERROR,
RCL_LOGGING_RET_INVALID_ARGUMENT,
rcl_logging_external_initialize(nullptr, nullptr, invalid_allocator));
rcutils_reset_error();
}
Expand Down