Skip to content

Commit

Permalink
Fix LTO linker warning
Browse files Browse the repository at this point in the history
`warning: ‘__builtin_strlen’ reading 1 or more bytes from a region of
size 0 [-Wstringop-overread]`

Signed-off-by: Frank Bielig <frank@bielig.info>
  • Loading branch information
frankbielig committed Nov 4, 2024
1 parent cf81df1 commit d02f076
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/osmium/builder/osm_object_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ namespace osmium {
* @pre @code strlen(user) < 2^16 - 1 @endcode
*/
TDerived& set_user(const char* user) {
const auto len = std::strlen(user);
const auto len = (user == nullptr) ? 0 : std::strlen(user);
assert(len < std::numeric_limits<string_size_type>::max());
return set_user(user, static_cast<string_size_type>(len));
}
Expand Down

0 comments on commit d02f076

Please sign in to comment.