cid#1607362 Overflowed constant

and

cid#1607419 Overflowed constant
cid#1608605 Overflowed constant

Change-Id: Ia63cc771021d8a8031c62582a2fa6a68dc214f08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173614
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Caolán McNamara
2024-09-17 17:00:13 +01:00
parent f8c56ecafb
commit b35a1ee2aa
3 changed files with 5 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -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";

View File

@@ -168,7 +168,8 @@ template<typename T> rtl::Reference<T> 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);
}