Skip to content

Commit

Permalink
Add bad_alloc return to topic_endpoint_info functions (#269)
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brawner <[email protected]>
  • Loading branch information
brawner authored Aug 28, 2020
1 parent ef2caa5 commit 3db0cfa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rmw/include/rmw/topic_endpoint_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ rmw_topic_endpoint_info_fini(
* \param[in] allocator the allocator that will be used to allocate memory
* \returns `RMW_RET_OK` on successfully setting the topic_type, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand All @@ -104,6 +105,7 @@ rmw_topic_endpoint_info_set_topic_type(
* \param[in] allocator the allocator that will be used to allocate memory
* \returns `RMW_RET_OK` on successfully setting the node_name, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand All @@ -126,6 +128,7 @@ rmw_topic_endpoint_info_set_node_name(
* \param[in] allocator the allocator that will be used to allocate memory
* \returns `RMW_RET_OK` on successfully setting the node_namespace, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand All @@ -148,6 +151,7 @@ rmw_topic_endpoint_info_set_node_namespace(
* \returns `RMW_RET_OK` on successfully setting the gid, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_INVALID_ARGUMENT` size is greater than RMW_GID_STORAGE_SIZE, or
* \returns `RMW_RET_BAD_ALLOC` if allocation for string duplication fails, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
Expand Down
3 changes: 3 additions & 0 deletions rmw/src/topic_endpoint_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ _rmw_topic_endpoint_info_copy_str(
}

*topic_endpoint_info_str = rcutils_strdup(str, *allocator);
if (NULL == *topic_endpoint_info_str) {
return RMW_RET_BAD_ALLOC;
}

return RMW_RET_OK;
}
Expand Down

0 comments on commit 3db0cfa

Please sign in to comment.