cid#1607989 Overflowed constant

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 <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara 2024-09-22 20:21:01 +01:00
parent dcde476695
commit 08964038e1
4 changed files with 11 additions and 4 deletions

View file

@ -1204,7 +1204,8 @@ OString NetProducer::getNetName(std::string_view name)
// if polymorphic, process parameters too // if polymorphic, process parameters too
if (fullNameView.ends_with('>')) 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; size_t end = fullNameView.size() - 1;
buffer.append(fullNameView.substr(0, start)); buffer.append(fullNameView.substr(0, start));
OString params(fullNameView.substr(start, end - start)); OString params(fullNameView.substr(start, end - start));

View file

@ -68,7 +68,9 @@ static void printType(
if (sort == codemaker::UnoType::Sort::Enum) { if (sort == codemaker::UnoType::Sort::Enum) {
auto pEnumTypeEntity(dynamic_cast<unoidl::EnumTypeEntity *>(entity.get())); auto pEnumTypeEntity(dynamic_cast<unoidl::EnumTypeEntity *>(entity.get()));
assert(pEnumTypeEntity); 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; << pEnumTypeEntity->getMembers()[0].name;
} }
return; return;

View file

@ -415,7 +415,9 @@ char const PERIOD[] = ". ";
static void addFileError(OUStringBuffer& _rBuf, std::u16string_view _aPath, AsciiString _sWhat) 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("The configuration file");
_rBuf.append(OUString::Concat(" '") + sSimpleFileName + "' "); _rBuf.append(OUString::Concat(" '") + sSimpleFileName + "' ");

View file

@ -31,7 +31,9 @@ namespace
OUString sMimeType; OUString sMimeType;
if (o3tl::starts_with(rString, u"vnd.sun.star.Package")) 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); sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aExtension);
} }
return sMimeType; return sMimeType;