From b35a1ee2aa85d42a749c4380feb252dc4c1e143c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 17 Sep 2024 17:00:13 +0100 Subject: [PATCH] cid#1607362 Overflowed constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Jenkins --- ucb/source/ucp/file/filglob.cxx | 2 +- unodevtools/source/skeletonmaker/javatypemaker.cxx | 3 ++- unoidl/source/sourceprovider-parser.y | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) 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); }