Skip to content

Commit

Permalink
strerror_r requires non-null buffer pointer
Browse files Browse the repository at this point in the history
Fixes -Wnonnull warnings when calling message with a nullptr buffer
  • Loading branch information
ashtum committed Jun 2, 2024
1 parent 8a92683 commit 4d4f906
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/boost/system/detail/generic_category_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ inline char const * strerror_r_helper( int r, char const * buffer ) noexcept

inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
{
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
if ( buffer != nullptr )
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );

// strerror_r requires non-null buffer pointer
char dummy_buffer[ 1 ];
return strerror_r_helper( strerror_r( ev, dummy_buffer, 0 ), buffer );
}

inline std::string generic_error_category_message( int ev )
Expand Down

0 comments on commit 4d4f906

Please sign in to comment.