Skip to content

Commit

Permalink
Fix rmw_validate_namespace{_with_size} error handling. (#386)
Browse files Browse the repository at this point in the history
* Fix rmw_validate_namespace{_with_size} error handling.

It should always set an error, even on invalid arguments.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Dec 24, 2024
1 parent 6d00aec commit eba8048
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions rmw/src/validate_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ rmw_validate_namespace(
int * validation_result,
size_t * invalid_index)
{
if (!namespace_) {
return RMW_RET_INVALID_ARGUMENT;
}
RCUTILS_CHECK_ARGUMENT_FOR_NULL(namespace_, RMW_RET_INVALID_ARGUMENT);

return rmw_validate_namespace_with_size(
namespace_, strlen(namespace_), validation_result, invalid_index);
}
Expand All @@ -43,12 +42,8 @@ rmw_validate_namespace_with_size(
int * validation_result,
size_t * invalid_index)
{
if (!namespace_) {
return RMW_RET_INVALID_ARGUMENT;
}
if (!validation_result) {
return RMW_RET_INVALID_ARGUMENT;
}
RCUTILS_CHECK_ARGUMENT_FOR_NULL(namespace_, RMW_RET_INVALID_ARGUMENT);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(validation_result, RMW_RET_INVALID_ARGUMENT);

// Special case for root namepsace
if (namespace_length == 1 && namespace_[0] == '/') {
Expand Down

0 comments on commit eba8048

Please sign in to comment.