diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx index ce719986961f..93fb4ad81a4d 100644 --- a/ucb/source/ucp/file/filglob.cxx +++ b/ucb/source/ucp/file/filglob.cxx @@ -187,7 +187,7 @@ namespace fileaccess { std::u16string_view getTitle( std::u16string_view aPath ) { size_t lastIndex = aPath.rfind( '/' ); - return aPath.substr( lastIndex + 1 ); + return aPath.substr((lastIndex != std::u16string_view::npos) ? lastIndex + 1 : 0); } diff --git a/unodevtools/source/skeletonmaker/javatypemaker.cxx b/unodevtools/source/skeletonmaker/javatypemaker.cxx index 639438799d48..49a86e87d866 100644 --- a/unodevtools/source/skeletonmaker/javatypemaker.cxx +++ b/unodevtools/source/skeletonmaker/javatypemaker.cxx @@ -252,7 +252,8 @@ static void printConstructor( rtl::Reference< unoidl::Entity > const & entity, std::u16string_view name, std::vector< OUString > const & arguments) { - o << "public " << OUString(name.substr(name.rfind('.') + 1)) << '('; + std::u16string_view::size_type pos = name.rfind('.'); + o << "public " << OUString(name.substr((pos != std::u16string_view::npos) ? pos + 1 : 0)) << '('; printConstructorParameters( o, options, manager, sort, entity, name, arguments); o << ");\n"; diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y index 0ce80ac5d9ac..2b126d4811bb 100644 --- a/unoidl/source/sourceprovider-parser.y +++ b/unoidl/source/sourceprovider-parser.y @@ -168,7 +168,8 @@ template rtl::Reference getCurrentPad( bool nameHasSameIdentifierAs(std::u16string_view name, std::u16string_view identifier) { - size_t i = name.rfind('.') + 1; + std::u16string_view::size_type pos = name.rfind('.'); + size_t i = (pos != std::u16string_view::npos) ? pos + 1 : 0; return identifier.size() == name.size() - i && o3tl::starts_with(name.substr(i), identifier); }