From 08964038e1432bcda91de1a7e5454ab4e8b114a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sun, 22 Sep 2024 20:21:01 +0100 Subject: [PATCH] cid#1607989 Overflowed constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and cid#1607976 Overflowed constant cid#1607855 Overflowed constant cid#1607731 Overflowed constant Change-Id: I18e8ffb8a9b5a55e0ecb71862549a94ff5c2fc1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173781 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- codemaker/source/netmaker/netproduce.cxx | 3 ++- unodevtools/source/skeletonmaker/cpptypemaker.cxx | 4 +++- unotools/source/config/bootstrap.cxx | 4 +++- xmloff/source/core/xmlmultiimagehelper.cxx | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/codemaker/source/netmaker/netproduce.cxx b/codemaker/source/netmaker/netproduce.cxx index d1fa788f28de..ab3495b9e641 100644 --- a/codemaker/source/netmaker/netproduce.cxx +++ b/codemaker/source/netmaker/netproduce.cxx @@ -1204,7 +1204,8 @@ OString NetProducer::getNetName(std::string_view name) // if polymorphic, process parameters too if (fullNameView.ends_with('>')) { - size_t start = fullNameView.find_first_of('<') + 1; + const std::string_view::size_type nFirstAngle = fullNameView.find_first_of('<'); + size_t start = (nFirstAngle != std::string_view::npos) ? (nFirstAngle + 1) : 0; size_t end = fullNameView.size() - 1; buffer.append(fullNameView.substr(0, start)); OString params(fullNameView.substr(start, end - start)); diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx b/unodevtools/source/skeletonmaker/cpptypemaker.cxx index 1423f2739a5b..5432957b9e86 100644 --- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx +++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx @@ -68,7 +68,9 @@ static void printType( if (sort == codemaker::UnoType::Sort::Enum) { auto pEnumTypeEntity(dynamic_cast(entity.get())); assert(pEnumTypeEntity); - o << OUString(nucleus.substr(nucleus.rfind('.') + 1)) << "_" + const std::string_view::size_type nLastDot = nucleus.rfind('.'); + const auto nAfterDot = (nLastDot != std::string_view::npos) ? (nLastDot + 1) : 0; + o << OUString(nucleus.substr(nAfterDot)) << "_" << pEnumTypeEntity->getMembers()[0].name; } return; diff --git a/unotools/source/config/bootstrap.cxx b/unotools/source/config/bootstrap.cxx index 5dcf43ee2942..8804a2229f36 100644 --- a/unotools/source/config/bootstrap.cxx +++ b/unotools/source/config/bootstrap.cxx @@ -415,7 +415,9 @@ char const PERIOD[] = ". "; static void addFileError(OUStringBuffer& _rBuf, std::u16string_view _aPath, AsciiString _sWhat) { - std::u16string_view sSimpleFileName = _aPath.substr(1 +_aPath.rfind(cURLSeparator)); + const std::string_view::size_type nLastSep = _aPath.rfind(cURLSeparator); + const auto nAfterSep = (nLastSep != std::string_view::npos) ? (nLastSep + 1) : 0; + std::u16string_view sSimpleFileName = _aPath.substr(nAfterSep); _rBuf.append("The configuration file"); _rBuf.append(OUString::Concat(" '") + sSimpleFileName + "' "); diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx index 99e4b1f6080d..87b38a5bc13d 100644 --- a/xmloff/source/core/xmlmultiimagehelper.cxx +++ b/xmloff/source/core/xmlmultiimagehelper.cxx @@ -31,7 +31,9 @@ namespace OUString sMimeType; if (o3tl::starts_with(rString, u"vnd.sun.star.Package")) { - OString aExtension = OUStringToOString(rString.substr(rString.rfind('.') + 1), RTL_TEXTENCODING_ASCII_US); + const std::string_view::size_type nLastDot = rString.rfind('.'); + const auto nAfterDot = (nLastDot != std::string_view::npos) ? (nLastDot + 1) : 0; + OString aExtension = OUStringToOString(rString.substr(nAfterDot), RTL_TEXTENCODING_ASCII_US); sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aExtension); } return sMimeType;