[Libreoffice-commits] core.git: registry/source reportdesign/source sal/osl sal/rtl

2023-03-25 Thread Noel Grandin (via logerrit)
 registry/source/regimpl.cxx  |3 +--
 reportdesign/source/ui/dlg/Navigator.cxx |6 ++
 sal/osl/unx/file_url.cxx |3 +--
 sal/rtl/uri.cxx  |2 +-
 4 files changed, 5 insertions(+), 9 deletions(-)

New commits:
commit 27b98e9e3b3d21fded40df1912292f381fae4ab0
Author: Noel Grandin 
AuthorDate: Sat Mar 25 18:56:09 2023 +0200
Commit: Noel Grandin 
CommitDate: Sat Mar 25 19:03:28 2023 +

loplugin:stringadd in registry..sal

after my patch to merge the bufferadd loplugin into stringadd

Change-Id: I1658b960d44780f7d9c447246b1178cb70be5e66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149581
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 5f5bf335edb4..7dcbaa272dab 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -643,8 +643,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, 
std::u16string_view keyName,
 return RegError::CREATE_KEY_FAILED;
 }
 
-sFullPath.append(token);
-sFullPath.append('/');
+sFullPath.append(token + "/");
 }
 } while(nIndex != -1);
 
diff --git a/reportdesign/source/ui/dlg/Navigator.cxx 
b/reportdesign/source/ui/dlg/Navigator.cxx
index 90cc2dc0d45b..24a4e253b849 100644
--- a/reportdesign/source/ui/dlg/Navigator.cxx
+++ b/reportdesign/source/ui/dlg/Navigator.cxx
@@ -82,16 +82,14 @@ static OUString lcl_getName(const uno::Reference< 
beans::XPropertySet>& _xElemen
 uno::Reference< report::XReportControlModel> 
xReportModel(_xElement,uno::UNO_QUERY);
 if ( xFixedText.is() )
 {
-sName.append(" : ");
-sName.append(xFixedText->getLabel());
+sName.append(" : " + xFixedText->getLabel());
 }
 else if ( xReportModel.is() && 
_xElement->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
 {
 ReportFormula aFormula( xReportModel->getDataField() );
 if ( aFormula.isValid() )
 {
-sName.append(" : ");
-sName.append( aFormula.getUndecoratedContent() );
+sName.append(" : " + aFormula.getUndecoratedContent() );
 }
 }
 return sName.makeStringAndClear();
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index 4b5a16885cb3..c69670d6373a 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -955,8 +955,7 @@ oslFileError osl::detail::convertPathnameToUrl(OString 
const & pathname, OUStrin
 static sal_Unicode const aHex[16]
 = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 }; /* '0'--'9', 
'A'--'F' */
-buf.append(aHex[c >> 4]);
-buf.append(aHex[c & 15]);
+buf.append(OUStringChar(aHex[c >> 4]) + OUStringChar(aHex[c & 
15]));
 --convert;
 continue;
 }
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index 3414552615e6..bb53385dbaab 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -143,7 +143,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, 
sal_Unicode const * pEnd,
 }
 else
 {
-OStringBuffer aBuf;
+OStringBuffer aBuf(16);
 aBuf.append(static_cast< char >(nChar));
 rtl_TextToUnicodeConverter aConverter
 = rtl_createTextToUnicodeConverter(eCharset);


[Libreoffice-commits] core.git: registry/source

2022-08-22 Thread Caolán McNamara (via logerrit)
 registry/source/regimpl.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 82406c37d4ff10453ebf2ed56dfe8ec961954aaf
Author: Caolán McNamara 
AuthorDate: Mon Aug 22 09:49:24 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Aug 22 13:12:49 2022 +0200

cid#1500700 silence Resource leak

Change-Id: I606583919bceac98b480f3821c349069611808b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138662
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index f33dbc7d5ebb..5f5bf335edb4 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -693,6 +693,7 @@ RegError ORegistry::openKey(RegKeyHandle hKey, 
std::u16string_view keyName,
 
 std::unique_ptr< ORegKey > p(new ORegKey(path, this));
 i = m_openKeyTable.insert(std::make_pair(path, p.get())).first;
+// coverity[leaked_storage : FALSE] - ownership transferred to 
m_openKeyTable
 p.release();
 } else {
 i->second->acquire();


[Libreoffice-commits] core.git: registry/source

2022-06-21 Thread Chris Sherlock (via logerrit)
 registry/source/keyimpl.cxx  |   57 
 registry/source/reflread.cxx |   53 +
 registry/source/registry.cxx |   42 ---
 registry/source/regkey.cxx   |   76 ---
 4 files changed, 3 insertions(+), 225 deletions(-)

New commits:
commit e02a7a55c23d23dd7afa2627a7e10c70e1cba001
Author: Chris Sherlock 
AuthorDate: Sun Jan 9 06:51:17 2022 +1100
Commit: Stephan Bergmann 
CommitDate: Tue Jun 21 20:22:34 2022 +0200

registry: remove unnecessary comments

Change-Id: I03b49dcf4bb668b0e4967eb4e88639a5a7e36c8e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128174
Reviewed-by: Stephan Bergmann 
Tested-by: Jenkins

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index abf8e0d1ef12..37efeda82ff1 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -34,9 +34,6 @@ using namespace store;
 
 namespace { char const VALUE_PREFIX[] = "$VL_"; }
 
-
-//  ORegKey()
-
 ORegKey::ORegKey(const OUString& keyName, ORegistry* pReg)
 : m_refCount(1)
 , m_name(keyName)
@@ -46,41 +43,26 @@ ORegKey::ORegKey(const OUString& keyName, ORegistry* pReg)
 {
 }
 
-
-//  ~ORegKey()
-
 ORegKey::~ORegKey()
 {
 SAL_WARN_IF(m_refCount != 0, "registry", "registry::ORegKey::dtor(): 
refcount not zero.");
 }
 
-
-//  releaseKey
-
 RegError ORegKey::releaseKey(RegKeyHandle hKey)
 {
 return m_pRegistry->releaseKey(hKey);
 }
 
-
-//  createKey
-
 RegError ORegKey::createKey(std::u16string_view keyName, RegKeyHandle* 
phNewKey)
 {
 return m_pRegistry->createKey(this, keyName, phNewKey);
 }
 
-
-//  openKey
-
 RegError ORegKey::openKey(std::u16string_view keyName, RegKeyHandle* phOpenKey)
 {
 return m_pRegistry->openKey(this, keyName, phOpenKey);
 }
 
-
-//  openSubKeys
-
 RegError ORegKey::openSubKeys(std::u16string_view keyName, RegKeyHandle** 
phOpenSubKeys, sal_uInt32* pnSubKeys)
 {
 RegError _ret = RegError::NO_ERROR;
@@ -139,9 +121,6 @@ RegError ORegKey::openSubKeys(std::u16string_view keyName, 
RegKeyHandle** phOpen
 return RegError::NO_ERROR;
 }
 
-
-//  getKeyNames
-
 RegError ORegKey::getKeyNames(std::u16string_view keyName,
   rtl_uString*** pSubKeyNames,
   sal_uInt32* pnSubKeys)
@@ -196,25 +175,16 @@ RegError ORegKey::getKeyNames(std::u16string_view keyName,
 return RegError::NO_ERROR;
 }
 
-
-//  closeKey
-
 RegError ORegKey::closeKey(RegKeyHandle hKey)
 {
 return m_pRegistry->closeKey(hKey);
 }
 
-
-//  deleteKey
-
 RegError ORegKey::deleteKey(std::u16string_view keyName)
 {
 return m_pRegistry->deleteKey(this, keyName);
 }
 
-
-//  getValueType
-
 RegError ORegKey::getValueInfo(std::u16string_view valueName, RegValueType* 
pValueType, sal_uInt32* pValueSize) const
 {
 OStoreStreamrValue;
@@ -267,9 +237,6 @@ RegError ORegKey::getValueInfo(std::u16string_view 
valueName, RegValueType* pVal
 return RegError::NO_ERROR;
 }
 
-
-//  setValue
-
 RegError ORegKey::setValue(std::u16string_view valueName, RegValueType vType, 
RegValue value, sal_uInt32 vSize)
 {
 OStoreStreamrValue;
@@ -338,9 +305,6 @@ RegError ORegKey::setValue(std::u16string_view valueName, 
RegValueType vType, Re
 return RegError::NO_ERROR;
 }
 
-
-//  setLongListValue
-
 RegError ORegKey::setLongListValue(std::u16string_view valueName, sal_Int32 
const * pValueList, sal_uInt32 len)
 {
 OStoreStreamrValue;
@@ -393,9 +357,6 @@ RegError ORegKey::setLongListValue(std::u16string_view 
valueName, sal_Int32 cons
 return RegError::NO_ERROR;
 }
 
-
-//  setStringListValue
-
 RegError ORegKey::setStringListValue(
 std::u16string_view valueName, char** pValueList, sal_uInt32 len)
 {
@@ -458,9 +419,6 @@ RegError ORegKey::setStringListValue(
 return RegError::NO_ERROR;
 }
 
-
-//  setUnicodeListValue
-
 RegError ORegKey::setUnicodeListValue(std::u16string_view valueName, 
sal_Unicode** pValueList, sal_uInt32 len)
 {
 OStoreStreamrValue;
@@ -522,9 +480,6 @@ RegError ORegKey::setUnicodeListValue(std::u16string_view 
valueName, sal_Unicode
 return RegError::NO_ERROR;
 }
 
-
-//  getValue
-
 RegError ORegKey::getValue(std::u16string_view valueName, RegValue value) const
 {
 OStoreStreamrValue;
@@ -601,9 +556,6 @@ RegError ORegKey::getValue(std::u16string_view valueName, 
RegValue value) const
 return RegError::NO_ERROR;
 }
 
-
-//  getLongListValue
-
 RegError ORegKey::getLongListValue(std::u16string_view valueName, sal_Int32** 
pValueList, sal_uInt32* pLen) const
 {
 OStoreStreamrValue;
@@ -704,9 +656,6 @@ RegError ORegKey::getLongListValue(std::u16string_view 
valueName, sal_Int32** pV
 return RegError::NO_ERROR;
 }
 
-
-//  getStringListValue
-
 RegError ORegKey::getStringListValue(std::u16string_view valueName, char*** 
pValueList, sal_uInt32* pLen) const
 {
 OStoreStreamrValue;
@@ -801,9 +750,6 @@ RegError ORegK

[Libreoffice-commits] core.git: registry/source

2022-06-11 Thread Stephan Bergmann (via logerrit)
 registry/source/reflcnst.hxx |   39 --
 registry/source/reflwrit.cxx |   49 ---
 2 files changed, 1 insertion(+), 87 deletions(-)

New commits:
commit 7e2f0f6c089b898056c0269299220593be1b22f8
Author: Stephan Bergmann 
AuthorDate: Wed May 11 09:18:04 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Sat Jun 11 09:59:09 2022 +0200

Remove some more dead functionality

Change-Id: I653c85d247b2d52c75e12fc0c54701616a44abd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134148
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/reflcnst.hxx b/registry/source/reflcnst.hxx
index 2254b94b511e..529d02f9d68a 100644
--- a/registry/source/reflcnst.hxx
+++ b/registry/source/reflcnst.hxx
@@ -51,11 +51,6 @@ extern const sal_uInt16 majorVersion;
 #define CP_OFFSET_ENTRY_SIZE0
 #define CP_OFFSET_ENTRY_TAG 
static_cast(CP_OFFSET_ENTRY_SIZE + sizeof(sal_uInt32))
 #define CP_OFFSET_ENTRY_DATA
static_cast(CP_OFFSET_ENTRY_TAG + sizeof(sal_uInt16))
-#define CP_OFFSET_ENTRY_UIK1
static_cast(CP_OFFSET_ENTRY_DATA)
-#define CP_OFFSET_ENTRY_UIK2
static_cast(CP_OFFSET_ENTRY_UIK1 + sizeof(sal_uInt32))
-#define CP_OFFSET_ENTRY_UIK3
static_cast(CP_OFFSET_ENTRY_UIK2 + sizeof(sal_uInt16))
-#define CP_OFFSET_ENTRY_UIK4
static_cast(CP_OFFSET_ENTRY_UIK3 + sizeof(sal_uInt16))
-#define CP_OFFSET_ENTRY_UIK5
static_cast(CP_OFFSET_ENTRY_UIK4 + sizeof(sal_uInt32))
 
 #define FIELD_OFFSET_ACCESS 0
 #define FIELD_OFFSET_NAME   
static_cast(FIELD_OFFSET_ACCESS + sizeof(sal_uInt16))
@@ -94,25 +89,9 @@ enum CPInfoTag
 CP_TAG_CONST_FLOAT = RT_TYPE_FLOAT,
 CP_TAG_CONST_DOUBLE = RT_TYPE_DOUBLE,
 CP_TAG_CONST_STRING = RT_TYPE_STRING,
-CP_TAG_UTF8_NAME,
-CP_TAG_UIK
+CP_TAG_UTF8_NAME
 };
 
-inline sal_uInt32 writeBYTE(sal_uInt8* buffer, sal_uInt8 v)
-{
-buffer[0] = v;
-
-return sizeof(sal_uInt8);
-}
-
-inline sal_uInt32 writeINT16(sal_uInt8* buffer, sal_Int16 v)
-{
-buffer[0] = static_cast((v >> 8) & 0xFF);
-buffer[1] = static_cast((v >> 0) & 0xFF);
-
-return sizeof(sal_Int16);
-}
-
 inline sal_uInt32 writeUINT16(sal_uInt8* buffer, sal_uInt16 v)
 {
 buffer[0] = static_cast((v >> 8) & 0xFF);
@@ -177,20 +156,6 @@ inline sal_uInt32 readUINT32(const sal_uInt8* buffer, 
sal_uInt32& v)
 return sizeof(sal_uInt32);
 }
 
-inline sal_uInt32 writeUINT64(sal_uInt8* buffer, sal_uInt64 v)
-{
-buffer[0] = static_cast((v >> 56) & 0xFF);
-buffer[1] = static_cast((v >> 48) & 0xFF);
-buffer[2] = static_cast((v >> 40) & 0xFF);
-buffer[3] = static_cast((v >> 32) & 0xFF);
-buffer[4] = static_cast((v >> 24) & 0xFF);
-buffer[5] = static_cast((v >> 16) & 0xFF);
-buffer[6] = static_cast((v >> 8) & 0xFF);
-buffer[7] = static_cast((v >> 0) & 0xFF);
-
-return sizeof(sal_uInt64);
-}
-
 inline sal_uInt32 writeUtf8(sal_uInt8* buffer, const char* v)
 {
 sal_uInt32 size = strlen(v) + 1;
@@ -216,8 +181,6 @@ inline sal_uInt32 readUtf8(const sal_uInt8* buffer, char* 
v, sal_uInt32 maxSize)
 }
 
 
-sal_uInt32 writeFloat(sal_uInt8* buffer, float v);
-sal_uInt32 writeDouble(sal_uInt8* buffer, double v);
 sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v);
 sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 
maxSize);
 
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index 7517f2458ffa..5304d03463c8 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -19,7 +19,6 @@
 
 
 #include 
-#include 
 #include 
 
 #include 
@@ -77,52 +76,4 @@ sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* 
v, sal_uInt32 maxSiz
 return (buff - buffer);
 }
 
-sal_uInt32 writeFloat(sal_uInt8* buffer, float v)
-{
-union
-{
-float   v;
-sal_uInt32  b;
-} x;
-
-x.v = v;
-
-#ifdef REGTYPE_IEEE_NATIVE
-writeUINT32(buffer, x.b);
-#else
-#   error no IEEE
-#endif
-
-return sizeof(sal_uInt32);
-}
-
-sal_uInt32 writeDouble(sal_uInt8* buffer, double v)
-{
-union
-{
-double v;
-struct
-{
-sal_uInt32  b1;
-sal_uInt32  b2;
-} b;
-} x;
-
-x.v = v;
-
-#ifdef REGTYPE_IEEE_NATIVE
-#   ifdef OSL_BIGENDIAN
-writeUINT32(buffer, x.b.b1);
-writeUINT32(buffer + sizeof(sal_uInt32), x.b.b2);
-#   else
-writeUINT32(buffer, x.b.b2);
-writeUINT32(buffer + sizeof(sal_uInt32), x.b.b1);
-#   endif
-#else
-#   error no IEEE
-#endif
-
-return (sizeof(sal_uInt32) + sizeof(sal_uInt32));
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: registry/source

2021-07-21 Thread Stephan Bergmann (via logerrit)
 registry/source/reflwrit.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 505fb3f952106d6fafd300097cce83c2050fbc60
Author: Stephan Bergmann 
AuthorDate: Wed Jul 21 17:16:19 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jul 22 08:15:30 2021 +0200

-Werror=maybe-uninitialized

> registry/source/reflwrit.cxx: In member function ‘sal_uInt32 
RegistryTypeWriter::getBlopSize()’:
> registry/source/reflwrit.cxx:1332:33: error: ‘size’ may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
>  1332 | return ::getBlopSize(m_hImpl);
>   | ^

at least with recent GCC 12 trunk and --enable-dbgutil --enable-optimized

Change-Id: I17abbb55ba31458147afd486a17e8455ede39b32
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119338
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index 04be2db6e702..8f8e83318433 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -1207,6 +1207,7 @@ void const * TYPEREG_CALLTYPE typereg_writer_getBlob(void 
* handle, sal_uInt32 *
 try {
 writer->createBlop();
 } catch (std::bad_alloc &) {
+*size = 0;
 return nullptr;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2021-01-15 Thread Caolán McNamara (via logerrit)
 registry/source/keyimpl.cxx |8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

New commits:
commit 729a07528cab3105d23276176ba17fca7fc2231c
Author: Caolán McNamara 
AuthorDate: Fri Jan 15 09:56:52 2021 +
Commit: Caolán McNamara 
CommitDate: Fri Jan 15 14:36:26 2021 +0100

cid#1471675 silence Logically dead code

Change-Id: I473ee1a4cf3ac6d90acf6872015a7ffa09239e48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109328
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index 00b227efe986..087e5855e6e1 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -581,9 +581,6 @@ RegError ORegKey::getValue(std::u16string_view valueName, 
RegValue value) const
 
 switch (valueType)
 {
-case RegValueType::NOT_DEFINED:
-memcpy(value, pBuffer.get(), valueSize);
-break;
 case RegValueType::LONG:
 readINT32(pBuffer.get(), *static_cast(value));
 break;
@@ -596,10 +593,7 @@ RegError ORegKey::getValue(std::u16string_view valueName, 
RegValue value) const
 case RegValueType::BINARY:
 memcpy(value, pBuffer.get(), valueSize);
 break;
-// coverity[dead_error_begin] - following conditions exist to avoid 
compiler warning
-case RegValueType::LONGLIST:
-case RegValueType::STRINGLIST:
-case RegValueType::UNICODELIST:
+default:
 memcpy(value, pBuffer.get(), valueSize);
 break;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2020-11-05 Thread Noel (via logerrit)
 registry/source/keyimpl.cxx  |4 +---
 registry/source/regimpl.cxx  |5 ++---
 registry/source/registry.cxx |8 ++--
 3 files changed, 5 insertions(+), 12 deletions(-)

New commits:
commit 45a7fbfb4fbb85297cc2756bb9d4aa5b65932274
Author: Noel 
AuthorDate: Thu Nov 5 11:25:21 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 5 12:58:52 2020 +0100

loplugin:reducevarscope in registry

Change-Id: I86a93530ea8d39157eb898715f6597d3f472785b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105334
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index e76512e9e19a..437aa3114e10 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -146,15 +146,13 @@ RegError ORegKey::getKeyNames(const OUString& keyName,
   rtl_uString*** pSubKeyNames,
   sal_uInt32* pnSubKeys)
 {
-RegError _ret = RegError::NO_ERROR;
-
 *pSubKeyNames = nullptr;
 *pnSubKeys = 0;
 
 ORegKey* pKey = this;
 if (!keyName.isEmpty())
 {
-_ret = openKey(keyName, reinterpret_cast(&pKey));
+RegError _ret = openKey(keyName, 
reinterpret_cast(&pKey));
 if (_ret != RegError::NO_ERROR)
 return _ret;
 }
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 60d90faa9c6c..13b9d4251802 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1018,8 +1018,6 @@ RegError ORegistry::checkBlop(OStoreStream& rValue,
 }
 
 std::vector aBuffer(VALUE_HEADERSIZE);
-RegValueTypevalueType;
-sal_uInt32  valueSize;
 sal_uInt32  rwBytes;
 OString targetPath(OUStringToOString(sTargetPath, 
RTL_TEXTENCODING_UTF8));
 
@@ -1027,7 +1025,8 @@ RegError ORegistry::checkBlop(OStoreStream& rValue,
 (rwBytes == VALUE_HEADERSIZE))
 {
 sal_uInt8 type = aBuffer[0];
-valueType = static_cast(type);
+RegValueType valueType = static_cast(type);
+sal_uInt32  valueSize;
 readUINT32(aBuffer.data() + VALUE_TYPEOFFSET, valueSize);
 
 if (valueType == RegValueType::BINARY)
diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx
index 166354aa5d62..eb2a38f6ba5a 100644
--- a/registry/source/registry.cxx
+++ b/registry/source/registry.cxx
@@ -162,11 +162,9 @@ static RegError REGISTRY_CALLTYPE 
openRegistry(rtl_uString* registryName,
 
 static RegError REGISTRY_CALLTYPE closeRegistry(RegHandle hReg)
 {
-ORegistry   *pReg;
-
 if (hReg)
 {
-pReg = static_cast(hReg);
+ORegistry *pReg = static_cast(hReg);
 if (!pReg->isOpen())
 return RegError::REGISTRY_NOT_OPEN;
 
@@ -192,11 +190,9 @@ static RegError REGISTRY_CALLTYPE closeRegistry(RegHandle 
hReg)
 static RegError REGISTRY_CALLTYPE destroyRegistry(RegHandle hReg,
   rtl_uString* registryName)
 {
-ORegistry   *pReg;
-
 if (hReg)
 {
-pReg = static_cast(hReg);
+ORegistry *pReg = static_cast(hReg);
 if (!pReg->isOpen())
 return RegError::INVALID_REGISTRY;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2020-09-05 Thread Stephan Bergmann (via logerrit)
 registry/source/regimpl.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit aa357e56e8b6185e66ce763ca48fff61fe718bd7
Author: Stephan Bergmann 
AuthorDate: Sat Sep 5 18:25:07 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Sat Sep 5 20:21:00 2020 +0200

Improve some OUString to OString conversions

...dropping an intermediary OUString temporary (assuming that way of
constructing an OUString temporary from a pointer was not chosen 
deliberately to
cut of the string at a potential embedded NUL).

(This change is a prerequisite for making the OUString ctor taking a raw 
pointer
explicit.)

Change-Id: I752a0e63b86cb5e3d1a97ede1d855b9602a353c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102081
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index f0c8162434d4..60d90faa9c6c 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1383,7 +1383,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, 
const OUString& sName, sal_
 std::unique_ptr value(new sal_Unicode[size]);
 readString(aBuffer.data(), value.get(), size);
 
-OString uStr = OUStringToOString(value.get(), 
RTL_TEXTENCODING_UTF8);
+OString uStr(value.get(), rtl_ustr_getLength(value.get()), 
RTL_TEXTENCODING_UTF8);
 fprintf(stdout, "L\"%s\"\n", uStr.getStr());
 }
 break;
@@ -1498,7 +1498,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, 
const OUString& sName, sal_
 if (offset > 8)
 fprintf(stdout, "%s  ", indent);
 
-uStr = OUStringToOString(pValue, RTL_TEXTENCODING_UTF8);
+uStr = OString(pValue, rtl_ustr_getLength(pValue), 
RTL_TEXTENCODING_UTF8);
 fprintf(
 stdout, "%lu = L\"%s\"\n",
 sal::static_int_cast< unsigned long >(i),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2020-09-05 Thread Stephan Bergmann (via logerrit)
 registry/source/regimpl.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 573f472c6d282c69d16d4ed985c7433c75876745
Author: Stephan Bergmann 
AuthorDate: Sat Sep 5 18:23:31 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Sat Sep 5 20:20:13 2020 +0200

Make printString take any std::u16string_view argument

(This change is a prerequisite for making the OUString ctor taking a raw 
pointer
explicit.)

Change-Id: I201c87e47ae83b7c3df39e5abb420d6a80b1d3e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102080
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 583cddd295d1..f0c8162434d4 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -20,8 +20,10 @@
 
 #include "regimpl.hxx"
 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -52,9 +54,9 @@ using namespace store;
 
 namespace {
 
-void printString(OUString const & s) {
+void printString(std::u16string_view s) {
 printf("\"");
-for (sal_Int32 i = 0; i < s.getLength(); ++i) {
+for (std::size_t i = 0; i < s.size(); ++i) {
 sal_Unicode c = s[i];
 if (c == '"' || c == '\\') {
 printf("\\%c", static_cast< char >(c));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2020-09-05 Thread Stephan Bergmann (via logerrit)
 registry/source/keyimpl.cxx |4 ++--
 registry/source/regimpl.cxx |   10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 7fc98802ecd6d9e198ae37269f10522286db987e
Author: Stephan Bergmann 
AuthorDate: Tue Sep 1 17:14:10 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Sat Sep 5 19:54:05 2020 +0200

Create OUString from storeFindData m_pszName and m_nLength

...assuming that (a) m_nLength does always reflect the actual m_pszName 
length,
and (b) that way of constructing an OUString from a pointer was not chosen
deliberately to cut of the string at a potential embedded NUL.

(This change is a prerequisite for making the OUString ctor taking a raw 
pointer
explicit.)

Change-Id: I75519825cd6b60a7c308a3697bfbfc40afb2d1c8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102076
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index f3cb2d00b34e..e76512e9e19a 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -111,7 +111,7 @@ RegError ORegKey::openSubKeys(const OUString& keyName, 
RegKeyHandle** phOpenSubK
 {
 if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR )
 {
-OUString const sSubKeyName = iter.m_pszName;
+OUString const sSubKeyName(iter.m_pszName, iter.m_nLength);
 
 ORegKey* pOpenSubKey = nullptr;
 _ret = pKey->openKey(sSubKeyName, 
reinterpret_cast(&pOpenSubKey));
@@ -175,7 +175,7 @@ RegError ORegKey::getKeyNames(const OUString& keyName,
 {
 if ( iter.m_nAttrib & STORE_ATTRIB_ISDIR)
 {
-OUString const sSubKeyName = iter.m_pszName;
+OUString const sSubKeyName(iter.m_pszName, iter.m_nLength);
 
 OUString sFullKeyName(pKey->getName());
 if (sFullKeyName.getLength() > 1)
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 000d82fdd927..583cddd295d1 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -820,7 +820,7 @@ RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey)
 
 while (_err == store_E_None)
 {
-OUString const keyName = iter.m_pszName;
+OUString const keyName(iter.m_pszName, iter.m_nLength);
 
 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
 {
@@ -867,7 +867,7 @@ RegError ORegistry::loadKey(RegKeyHandle hKey, const 
OUString& regFileName,
 
 while (_err == store_E_None)
 {
-OUString const keyName = iter.m_pszName;
+OUString const keyName(iter.m_pszName, iter.m_nLength);
 
 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
 {
@@ -1221,7 +1221,7 @@ RegError ORegistry::loadAndSaveKeys(ORegKey* pTargetKey,
 
 while (_err == store_E_None)
 {
-OUString const sName = iter.m_pszName;
+OUString const sName(iter.m_pszName, iter.m_nLength);
 
 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
 {
@@ -1266,7 +1266,7 @@ RegError ORegistry::dumpRegistry(RegKeyHandle hKey) const
 
 while (_err == store_E_None)
 {
-sName = iter.m_pszName;
+sName = OUString(iter.m_pszName, iter.m_nLength);
 
 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
 {
@@ -1552,7 +1552,7 @@ RegError ORegistry::dumpKey(const OUString& sPath, const 
OUString& sName, sal_In
 
 while (_err == store_E_None)
 {
-sSubName = iter.m_pszName;
+sSubName = OUString(iter.m_pszName, iter.m_nLength);
 
 if (iter.m_nAttrib & STORE_ATTRIB_ISDIR)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2020-08-28 Thread Stephan Bergmann (via logerrit)
 registry/source/regimpl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e28a1c232377e6f04e0b6dfe8b2e30fe5341f1d9
Author: Stephan Bergmann 
AuthorDate: Thu Aug 27 17:00:28 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Sat Aug 29 08:10:59 2020 +0200

Simplify OUStringBuffer to OUString conversion

Change-Id: Icbec786bda1eeba34d3575706a8064a40b0a1311
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101567
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index e58e99b4cdf7..000d82fdd927 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -640,7 +640,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const 
OUString& keyName,
 token = sFullKeyName.getToken(0, '/', nIndex);
 if (!token.isEmpty())
 {
-if (rStoreDir.create(pKey->getStoreFile(), sFullPath.getStr(), 
token, storeAccessMode::Create))
+if (rStoreDir.create(pKey->getStoreFile(), sFullPath.toString(), 
token, storeAccessMode::Create))
 {
 return RegError::CREATE_KEY_FAILED;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2020-07-01 Thread Stephan Bergmann (via logerrit)
 registry/source/keyimpl.cxx  |2 +-
 registry/source/reflread.cxx |4 ++--
 registry/source/reflwrit.cxx |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 21a30e3f1172bef710ca017558dca670f0790013
Author: Stephan Bergmann 
AuthorDate: Wed Jul 1 16:19:06 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Jul 1 21:14:48 2020 +0200

Upcoming improved loplugin:staticanonymous -> redundantstatic: registry

Change-Id: Id96932c7944b5136f5fa7b5f698b8bb3b616e9ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97633
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index e14a88ec2576..f3cb2d00b34e 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -32,7 +32,7 @@
 
 using namespace store;
 
-namespace { static char const VALUE_PREFIX[] = "$VL_"; }
+namespace { char const VALUE_PREFIX[] = "$VL_"; }
 
 
 //  ORegKey()
diff --git a/registry/source/reflread.cxx b/registry/source/reflread.cxx
index 89c9cbf9c35a..57884e110075 100644
--- a/registry/source/reflread.cxx
+++ b/registry/source/reflread.cxx
@@ -37,8 +37,8 @@
 
 #include 
 
-static const char NULL_STRING[1] = { 0 };
-static const sal_Unicode NULL_WSTRING[1] = { 0 };
+const char NULL_STRING[1] = { 0 };
+const sal_Unicode NULL_WSTRING[1] = { 0 };
 
 const sal_uInt32magic = 0x12345678;
 const sal_uInt16 minorVersion = 0x;
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index 48d28ab8766b..04be2db6e702 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -44,7 +44,7 @@ OString toByteString(rtl_uString const * str) {
 
 }
 
-static const sal_Unicode NULL_WSTRING[1] = { 0 };
+const sal_Unicode NULL_WSTRING[1] = { 0 };
 
 #define BLOP_OFFSET_MAGIC   0
 #define BLOP_OFFSET_SIZE(BLOP_OFFSET_MAGIC + sizeof(sal_uInt32))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2019-12-05 Thread Andrea Gelmini (via logerrit)
 registry/source/reflwrit.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 862a0dbb45cc403816c437cd590b9e5c6c5b9845
Author: Andrea Gelmini 
AuthorDate: Wed Dec 4 20:22:31 2019 +0100
Commit: Julien Nabet 
CommitDate: Thu Dec 5 10:21:12 2019 +0100

Fix typo

Change-Id: Ib8cbd86cfc31fb02e2d596ae4f956ac03dde0d1e
Reviewed-on: https://gerrit.libreoffice.org/84488
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/registry/source/reflwrit.hxx b/registry/source/reflwrit.hxx
index 0a985ff4b4d4..93cee0697381 100644
--- a/registry/source/reflwrit.hxx
+++ b/registry/source/reflwrit.hxx
@@ -46,7 +46,7 @@ public:
 @param typeName specifies the full qualified type name with '/' as 
separator.
 @param superTypeName specifies the full qualified type name of the 
base type
  with '/' as separator.
-@param fieldCount specifies the number of fields (eg. number of 
attrbutes/properties,
+@param fieldCount specifies the number of fields (eg. number of 
attributes/properties,
   enum values or constants).
  */
 RegistryTypeWriter(RTTypeClass   RTTypeClass,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: registry/source

2019-10-03 Thread Tor Lillqvist (via logerrit)
 registry/source/reflwrit.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 6ad127ead70cc0942c9876556dda7f525d7d01a0
Author: Tor Lillqvist 
AuthorDate: Thu Oct 3 16:48:04 2019 +0300
Commit: Tor Lillqvist 
CommitDate: Thu Oct 3 17:35:37 2019 +0200

tdf#127766: Avoid ODR violation for class/struct FieldEntry

We had a class FieldEntry in registry/source/reflwrit.cxx and a struct
FieldEntry in sd/source/filter/eppt/text.hxx. That causes problems
when code from both is linked into one binary, as in the iOS and
Android apps. The wrong FieldEntry destructor got called from the code
in sd which of course lead to a crash.

Fix by putting the one in registry into an unnamed namespace. (I put a
large chunk of the source file in it while at it.)

Change-Id: I1b32075f7aba256129b36ceb38eba605c882b9ff
Reviewed-on: https://gerrit.libreoffice.org/80141
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index afb01d96b213..25937eea8f8d 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -165,6 +165,7 @@ sal_uInt32 writeDouble(sal_uInt8* buffer, double v)
 
 **/
 
+namespace {
 
 /**
 
@@ -1098,6 +1099,7 @@ void TypeWriter::createBlop()
 m_blopSize = blopSize;
 }
 
+} // unnamed namespace
 
 /**
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: registry/source

2018-08-30 Thread Libreoffice Gerrit user
 registry/source/keyimpl.cxx |  217 +---
 1 file changed, 84 insertions(+), 133 deletions(-)

New commits:
commit fbb2d771681709e8d40f844d16e9a487a813
Author: Noel Grandin 
AuthorDate: Wed Aug 29 13:02:22 2018 +0200
Commit: Noel Grandin 
CommitDate: Thu Aug 30 11:10:06 2018 +0200

loplugin:useuniqueptr in registry

Change-Id: Ia2f9340183e76e6d46ea51ca62c7a731264f621c
Reviewed-on: https://gerrit.libreoffice.org/59773
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index 7dcd088ceaa5..a717c5df6764 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace store;
 
@@ -218,7 +219,7 @@ RegError ORegKey::deleteKey(const OUString& keyName)
 RegError ORegKey::getValueInfo(const OUString& valueName, RegValueType* 
pValueType, sal_uInt32* pValueSize) const
 {
 OStoreStreamrValue;
-sal_uInt8*  pBuffer;
+std::unique_ptr pBuffer;
 storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
 if (m_pRegistry->isReadOnly())
@@ -238,23 +239,21 @@ RegError ORegKey::getValueInfo(const OUString& valueName, 
RegValueType* pValueTy
 return RegError::VALUE_NOT_EXISTS;
 }
 
-pBuffer = static_cast(std::malloc(VALUE_HEADERSIZE));
+pBuffer.reset(new sal_uInt8[VALUE_HEADERSIZE]);
 
 sal_uInt32  readBytes;
-if ( rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, readBytes) )
+if ( rValue.readAt(0, pBuffer.get(), VALUE_HEADERSIZE, readBytes) )
 {
-std::free(pBuffer);
 return RegError::INVALID_VALUE;
 }
 if (readBytes != VALUE_HEADERSIZE)
 {
-std::free(pBuffer);
 return RegError::INVALID_VALUE;
 }
 
 sal_uInt32  size;
-sal_uInt8   type = *pBuffer;
-readUINT32(pBuffer+VALUE_TYPEOFFSET, size);
+sal_uInt8   type = pBuffer[0];
+readUINT32(pBuffer.get()+VALUE_TYPEOFFSET, size);
 
 *pValueType = static_cast(type);
 //if (*pValueType == RegValueType::UNICODE)
@@ -264,17 +263,15 @@ RegError ORegKey::getValueInfo(const OUString& valueName, 
RegValueType* pValueTy
 //{
 if (*pValueType > RegValueType::BINARY)
 {
-std::free(pBuffer);
-pBuffer = static_cast(std::malloc(4));
-rValue.readAt(VALUE_HEADEROFFSET, pBuffer, 4, readBytes);
+pBuffer.reset(new sal_uInt8[4]);
+rValue.readAt(VALUE_HEADEROFFSET, pBuffer.get(), 4, readBytes);
 
-readUINT32(pBuffer, size);
+readUINT32(pBuffer.get(), size);
 }
 
 *pValueSize = size;
 //}
 
-std::free(pBuffer);
 return RegError::NO_ERROR;
 }
 
@@ -284,7 +281,7 @@ RegError ORegKey::getValueInfo(const OUString& valueName, 
RegValueType* pValueTy
 RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, 
RegValue value, sal_uInt32 vSize)
 {
 OStoreStreamrValue;
-sal_uInt8*  pBuffer;
+std::unique_ptr pBuffer;
 
 if (m_pRegistry->isReadOnly())
 {
@@ -309,27 +306,27 @@ RegError ORegKey::setValue(const OUString& valueName, 
RegValueType vType, RegVal
 sal_uInt32 size = vSize;
 
 sal_uInt8 type = static_cast(vType);
-pBuffer = static_cast(std::malloc(VALUE_HEADERSIZE + size));
-memcpy(pBuffer, &type, 1);
+pBuffer.reset(new sal_uInt8[VALUE_HEADERSIZE + size]);
+memcpy(pBuffer.get(), &type, 1);
 
-writeUINT32(pBuffer+VALUE_TYPEOFFSET, size);
+writeUINT32(pBuffer.get()+VALUE_TYPEOFFSET, size);
 
 switch (vType)
 {
 case RegValueType::NOT_DEFINED:
-memcpy(pBuffer+VALUE_HEADEROFFSET, value, size);
+memcpy(pBuffer.get()+VALUE_HEADEROFFSET, value, size);
 break;
 case RegValueType::LONG:
-writeINT32(pBuffer+VALUE_HEADEROFFSET, 
*static_cast(value));
+writeINT32(pBuffer.get()+VALUE_HEADEROFFSET, 
*static_cast(value));
 break;
 case RegValueType::STRING:
-writeUtf8(pBuffer+VALUE_HEADEROFFSET, static_cast(value));
+writeUtf8(pBuffer.get()+VALUE_HEADEROFFSET, static_cast(value));
 break;
 case RegValueType::UNICODE:
-writeString(pBuffer+VALUE_HEADEROFFSET, static_cast(value));
+writeString(pBuffer.get()+VALUE_HEADEROFFSET, static_cast(value));
 break;
 case RegValueType::BINARY:
-memcpy(pBuffer+VALUE_HEADEROFFSET, value, size);
+memcpy(pBuffer.get()+VALUE_HEADEROFFSET, value, size);
 break;
 default:
 OSL_ASSERT(false);
@@ -337,19 +334,16 @@ RegError ORegKey::setValue(const OUString& valueName, 
RegValueType vType, RegVal
 }
 
 sal_uInt32  writenBytes;
-if ( rValue.writeAt(0, pBuffer, VALUE_HEADERSIZE+size, writenBytes) )
+if ( rValue.writeAt(0, pBuffer.get(), VALUE_HEADERSIZE+size, writenBytes) )
   

[Libreoffice-commits] core.git: registry/source

2018-07-26 Thread Libreoffice Gerrit user
 registry/source/regimpl.cxx |  110 +++-
 1 file changed, 39 insertions(+), 71 deletions(-)

New commits:
commit 1d023f5bba0bd29a94bb252009e5e217849239f8
Author: Caolán McNamara 
AuthorDate: Thu Jul 26 11:45:02 2018 +0100
Commit: Caolán McNamara 
CommitDate: Thu Jul 26 22:04:03 2018 +0200

Related: rhbz#1602589 double_free, convert to std::vector

Change-Id: I5fa19422d7ee61e7aad74eae86d843072e94016c
Reviewed-on: https://gerrit.libreoffice.org/58087
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 0bb4b2126ffa..79279b1f3f90 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -21,6 +21,7 @@
 #include "regimpl.hxx"
 
 #include 
+#include 
 #include 
 #include 
 
@@ -903,7 +904,6 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
  bool bReport)
 {
 OStoreStreamrValue;
-sal_uInt8*  pBuffer;
 RegValueTypevalueType;
 sal_uInt32  valueSize;
 sal_uInt32  nSize;
@@ -937,37 +937,32 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
 return RegError::VALUE_NOT_EXISTS;
 }
 
-pBuffer = static_cast(rtl_allocateMemory(VALUE_HEADERSIZE));
+std::vector aBuffer(VALUE_HEADERSIZE);
 
 sal_uInt32  rwBytes;
-if (rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, rwBytes))
+if (rValue.readAt(0, aBuffer.data(), VALUE_HEADERSIZE, rwBytes))
 {
-rtl_freeMemory(pBuffer);
 return RegError::INVALID_VALUE;
 }
 if (rwBytes != VALUE_HEADERSIZE)
 {
-rtl_freeMemory(pBuffer);
 return RegError::INVALID_VALUE;
 }
 
 RegError _ret = RegError::NO_ERROR;
-sal_uInt8   type = *pBuffer;
+sal_uInt8   type = aBuffer[0];
 valueType = static_cast(type);
-readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize);
-rtl_freeMemory(pBuffer);
+readUINT32(aBuffer.data() + VALUE_TYPEOFFSET, valueSize);
 
 nSize = VALUE_HEADERSIZE + valueSize;
-pBuffer = static_cast(rtl_allocateMemory(nSize));
+aBuffer.resize(nSize);
 
-if (rValue.readAt(0, pBuffer, nSize, rwBytes))
+if (rValue.readAt(0, aBuffer.data(), nSize, rwBytes))
 {
-rtl_freeMemory(pBuffer);
 return RegError::INVALID_VALUE;
 }
 if (rwBytes != nSize)
 {
-rtl_freeMemory(pBuffer);
 return RegError::INVALID_VALUE;
 }
 
@@ -978,19 +973,17 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
 if (valueType == RegValueType::BINARY)
 {
 _ret = checkBlop(
-rValue, sTargetPath, valueSize, pBuffer+VALUE_HEADEROFFSET,
+rValue, sTargetPath, valueSize, aBuffer.data() + 
VALUE_HEADEROFFSET,
 bReport);
 if (_ret != RegError::NO_ERROR)
 {
 if (_ret == RegError::MERGE_ERROR ||
 (_ret == RegError::MERGE_CONFLICT && bWarnings))
 {
-rtl_freeMemory(pBuffer);
 return _ret;
 }
 } else
 {
-rtl_freeMemory(pBuffer);
 return _ret;
 }
 }
@@ -998,23 +991,19 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
 
 if (rValue.create(rTargetFile, sTargetPath, valueName, 
storeAccessMode::Create))
 {
-rtl_freeMemory(pBuffer);
 return RegError::INVALID_VALUE;
 }
-if (rValue.writeAt(0, pBuffer, nSize, rwBytes))
+if (rValue.writeAt(0, aBuffer.data(), nSize, rwBytes))
 {
-rtl_freeMemory(pBuffer);
 return RegError::INVALID_VALUE;
 }
 
 if (rwBytes != nSize)
 {
-rtl_freeMemory(pBuffer);
 return RegError::INVALID_VALUE;
 }
 pTargetKey->setModified();
 
-rtl_freeMemory(pBuffer);
 return _ret;
 }
 
@@ -1031,33 +1020,30 @@ RegError ORegistry::checkBlop(OStoreStream& rValue,
 return RegError::INVALID_VALUE;
 }
 
-sal_uInt8*  pBuffer = 
static_cast(rtl_allocateMemory(VALUE_HEADERSIZE));
+std::vector aBuffer(VALUE_HEADERSIZE);
 RegValueTypevalueType;
 sal_uInt32  valueSize;
 sal_uInt32  rwBytes;
 OString targetPath(OUStringToOString(sTargetPath, 
RTL_TEXTENCODING_UTF8));
 
-if (!rValue.readAt(0, pBuffer, VALUE_HEADERSIZE, rwBytes) &&
+if (!rValue.readAt(0, aBuffer.data(), VALUE_HEADERSIZE, rwBytes) &&
 (rwBytes == VALUE_HEADERSIZE))
 {
-sal_uInt8 type = *pBuffer;
+sal_uInt8 type = aBuffer[0];
 valueType = static_cast(type);
-readUINT32(pBuffer+VALUE_TYPEOFFSET, valueSize);
-rtl_freeMemory(pBuffer);
+readUINT32(aBuffer.data() + VALUE_TYPEOFFSET, valueSize);
 
 if (valueType == RegValueType::BINARY)
 {
-pBuffer = static_cast(rtl_allocateMemory(va

[Libreoffice-commits] core.git: registry/source

2018-07-26 Thread Libreoffice Gerrit user
 registry/source/reflwrit.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit d9f81ecb1f8a6142379d85a7c6b1fdb54c57ad22
Author: Caolán McNamara 
AuthorDate: Thu Jul 26 10:48:53 2018 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Jul 26 16:26:18 2018 +0200

Related: rhbz#1602589 silence error[memleak]: Memory leak: newValue

Change-Id: I2d04c75aa9b5e1d91e06992fdb99899657ecf96d
Reviewed-on: https://gerrit.libreoffice.org/58062
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index 53b6d9d0e175..dc3e2a15b603 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -377,11 +377,11 @@ void FieldEntry::setData(const OString&name,
  RTValueTypeconstValueType,
  RTConstValueUnion  constValue)
 {
-sal_Unicode * newValue = nullptr;
+std::unique_ptr newValue;
 if (constValueType == RT_TYPE_STRING && constValue.aString != nullptr) {
 sal_Int32 n = rtl_ustr_getLength(constValue.aString) + 1;
-newValue = new sal_Unicode[n];
-memcpy(newValue, constValue.aString, n * sizeof (sal_Unicode));
+newValue.reset(new sal_Unicode[n]);
+memcpy(newValue.get(), constValue.aString, n * sizeof (sal_Unicode));
 }
 
 m_name = name;
@@ -407,7 +407,7 @@ void FieldEntry::setData(const OString&name,
 m_constValue.aString = NULL_WSTRING;
 else
 {
-m_constValue.aString = newValue;
+m_constValue.aString = newValue.release();
 }
 }
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2017-05-26 Thread Chris Sherlock
 registry/source/regimpl.hxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 5628195324941e29af1713ca3dd60bfcdc7a1ad8
Author: Chris Sherlock 
Date:   Sat May 27 00:10:52 2017 +1000

registry: fix indenting caused by automated namespace scripts, etc.

Change-Id: Ia14ebebafe957891f8a3f0b1bf8519e906211ef8
Reviewed-on: https://gerrit.libreoffice.org/38076
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx
index 8d9ed6185d91..4e96a8818747 100644
--- a/registry/source/regimpl.hxx
+++ b/registry/source/regimpl.hxx
@@ -137,13 +137,13 @@ private:
 
 typedef std::unordered_map< OUString, ORegKey*, OUStringHash > KeyMap;
 
-sal_uInt32  m_refCount;
+sal_uInt32  m_refCount;
 osl::Mutex  m_mutex;
-boolm_readOnly;
-boolm_isOpen;
-OUString   m_name;
+boolm_readOnly;
+boolm_isOpen;
+OUStringm_name;
 store::OStoreFile   m_file;
-KeyMap  m_openKeyTable;
+KeyMap  m_openKeyTable;
 
 const OUString ROOT;
 };
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2017-05-26 Thread Chris Sherlock
 registry/source/regimpl.cxx |   64 
 1 file changed, 64 deletions(-)

New commits:
commit 56824276de139cb5ed8b5f6d115724712a8ca4ef
Author: Chris Sherlock 
Date:   Fri May 26 22:20:56 2017 +1000

registry: remove comment cruft from regimpl.cxx

Change-Id: Ic728b6d975cfaf59c5d28c5587c488a245b4c961
Reviewed-on: https://gerrit.libreoffice.org/38068
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index a9ee6289d844..21a15d4c9f69 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -421,9 +421,6 @@ void dumpType(typereg::Reader const & reader, OString const 
& indent) {
 
 }
 
-
-//  ORegistry()
-
 ORegistry::ORegistry()
 : m_refCount(1)
 , m_readOnly(false)
@@ -432,9 +429,6 @@ ORegistry::ORegistry()
 {
 }
 
-
-//  ~ORegistry()
-
 ORegistry::~ORegistry()
 {
 ORegKey* pRootKey = m_openKeyTable[ROOT];
@@ -445,9 +439,6 @@ ORegistry::~ORegistry()
 m_file.close();
 }
 
-
-//  initRegistry
-
 RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode 
accessMode, bool bCreate)
 {
 RegError eRet = RegError::INVALID_REGISTRY;
@@ -511,9 +502,6 @@ RegError ORegistry::initRegistry(const OUString& regName, 
RegAccessMode accessMo
 return eRet;
 }
 
-
-//  closeRegistry
-
 RegError ORegistry::closeRegistry()
 {
 REG_GUARD(m_mutex);
@@ -530,9 +518,6 @@ RegError ORegistry::closeRegistry()
 }
 }
 
-
-//  destroyRegistry
-
 RegError ORegistry::destroyRegistry(const OUString& regName)
 {
 REG_GUARD(m_mutex);
@@ -592,9 +577,6 @@ RegError ORegistry::destroyRegistry(const OUString& regName)
 return RegError::NO_ERROR;
 }
 
-
-//  acquireKey
-
 RegError ORegistry::acquireKey (RegKeyHandle hKey)
 {
 ORegKey* pKey = static_cast< ORegKey* >(hKey);
@@ -607,9 +589,6 @@ RegError ORegistry::acquireKey (RegKeyHandle hKey)
 return RegError::NO_ERROR;
 }
 
-
-//  releaseKey
-
 RegError ORegistry::releaseKey (RegKeyHandle hKey)
 {
 ORegKey* pKey = static_cast< ORegKey* >(hKey);
@@ -625,9 +604,6 @@ RegError ORegistry::releaseKey (RegKeyHandle hKey)
 return RegError::NO_ERROR;
 }
 
-
-//  createKey
-
 RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName,
   RegKeyHandle* phNewKey)
 {
@@ -685,9 +661,6 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const 
OUString& keyName,
 return RegError::NO_ERROR;
 }
 
-
-//  openKey
-
 RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName,
 RegKeyHandle* phOpenKey)
 {
@@ -733,9 +706,6 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const 
OUString& keyName,
 return RegError::NO_ERROR;
 }
 
-
-//  closeKey
-
 RegError ORegistry::closeKey(RegKeyHandle hKey)
 {
 ORegKey* pKey = static_cast< ORegKey* >(hKey);
@@ -766,9 +736,6 @@ RegError ORegistry::closeKey(RegKeyHandle hKey)
 return releaseKey(pKey);
 }
 
-
-//  deleteKey
-
 RegError ORegistry::deleteKey(RegKeyHandle hKey, const OUString& keyName)
 {
 ORegKey* pKey = static_cast< ORegKey* >(hKey);
@@ -848,9 +815,6 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& 
keyName)
 return pKey->closeKey(pOldKey);
 }
 
-
-//  deleteSubKeysAndValues
-
 RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey)
 {
 OStoreDirectory::iterator   iter;
@@ -888,9 +852,6 @@ RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey)
 return RegError::NO_ERROR;
 }
 
-
-//  loadKey
-
 RegError ORegistry::loadKey(RegKeyHandle hKey, const OUString& regFileName,
 bool bWarnings, bool bReport)
 {
@@ -934,9 +895,6 @@ RegError ORegistry::loadKey(RegKeyHandle hKey, const 
OUString& regFileName,
 return _ret;
 }
 
-
-//  loadAndSaveValue()
-
 RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
  ORegKey* pSourceKey,
  const OUString& valueName,
@@ -1038,7 +996,6 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
 }
 }
 
-// write
 if (rValue.create(rTargetFile, sTargetPath, valueName, 
storeAccessMode::Create))
 {
 rtl_freeMemory(pBuffer);
@@ -1061,9 +1018,6 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
 return _ret;
 }
 
-
-//  checkblop()
-
 RegError ORegistry::checkBlop(OStoreStream& rValue,
   const OUString& sTargetPath,
   sal_uInt32 srcValueSize,
@@ -1190,9 +1144,6 @@ static sal_uInt32 checkTypeReaders(RegistryTypeReader& 
reader1,
 return count;
 }
 
-
-//  mergeModuleValue()
-
 RegError ORegistry::mergeModuleValue(OStoreStream& rTargetValue,
  RegistryTypeReader& reader,
  RegistryTypeReader& reader2)
@@ -1263,9 +1214,6 @@ RegError ORegistry::mergeModuleValue(OStoreStream& 
rTargetValue,
 return RegError::N

[Libreoffice-commits] core.git: registry/source

2017-05-26 Thread Chris Sherlock
 registry/source/regimpl.cxx |   50 ++--
 1 file changed, 25 insertions(+), 25 deletions(-)

New commits:
commit 90347af0b41fa76a2a79a2b4c9258333b3bf9a25
Author: Chris Sherlock 
Date:   Fri May 26 22:29:15 2017 +1000

registry: like Rosencrantz, consistency is all I ask...

... only I do so with less existential angst.

Change-Id: Ib62c27580db845b5c00b772aef1ec798a6163b4a
Reviewed-on: https://gerrit.libreoffice.org/38070
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 5499e7b5c7da..a9ee6289d844 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -428,7 +428,7 @@ ORegistry::ORegistry()
 : m_refCount(1)
 , m_readOnly(false)
 , m_isOpen(false)
-, ROOT( "/" )
+, ROOT("/")
 {
 }
 
@@ -495,7 +495,7 @@ RegError ORegistry::initRegistry(const OUString& regName, 
RegAccessMode accessMo
 OStoreDirectory rStoreDir;
 storeError _err = rStoreDir.create(rRegFile, OUString(), OUString(), 
sAccessMode);
 
-if ( _err == store_E_None )
+if (_err == store_E_None)
 {
 m_file = rRegFile;
 m_name = regName;
@@ -546,10 +546,10 @@ RegError ORegistry::destroyRegistry(const OUString& 
regName)
 pReg.reset();
 
 OUString systemName;
-if ( FileBase::getSystemPathFromFileURL(regName, systemName) != 
FileBase::E_None )
+if (FileBase::getSystemPathFromFileURL(regName, systemName) != 
FileBase::E_None)
 systemName = regName;
 
-OString name( OUStringToOString(systemName, 
osl_getThreadTextEncoding()) );
+OString name(OUStringToOString(systemName, 
osl_getThreadTextEncoding()));
 if (unlink(name.getStr()) != 0)
 {
 return RegError::DESTROY_REGISTRY_FAILED;
@@ -574,10 +574,10 @@ RegError ORegistry::destroyRegistry(const OUString& 
regName)
 if (!m_name.isEmpty())
 {
 OUString systemName;
-if ( FileBase::getSystemPathFromFileURL(m_name, systemName) != 
FileBase::E_None )
+if (FileBase::getSystemPathFromFileURL(m_name, systemName) != 
FileBase::E_None)
 systemName = m_name;
 
-OString name( OUStringToOString(systemName, 
osl_getThreadTextEncoding()) );
+OString name(OUStringToOString(systemName, 
osl_getThreadTextEncoding()));
 if (unlink(name.getStr()) != 0)
 {
 return RegError::DESTROY_REGISTRY_FAILED;
@@ -635,7 +635,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const 
OUString& keyName,
 
 *phNewKey = nullptr;
 
-if ( keyName.isEmpty() )
+if (keyName.isEmpty())
 return RegError::INVALID_KEYNAME;
 
 REG_GUARD(m_mutex);
@@ -664,7 +664,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const 
OUString& keyName,
 sal_Int32 nIndex = 0;
 do
 {
-token = sFullKeyName.getToken( 0, '/', nIndex );
+token = sFullKeyName.getToken(0, '/', nIndex);
 if (!token.isEmpty())
 {
 if (rStoreDir.create(pKey->getStoreFile(), sFullPath.getStr(), 
token, storeAccessMode::Create))
@@ -675,7 +675,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const 
OUString& keyName,
 sFullPath.append(token);
 sFullPath.append('/');
 }
-} while( nIndex != -1 );
+} while(nIndex != -1);
 
 
 pKey = new ORegKey(sFullKeyName, this);
@@ -695,7 +695,7 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const 
OUString& keyName,
 
 *phOpenKey = nullptr;
 
-if ( keyName.isEmpty() )
+if (keyName.isEmpty())
 {
 return RegError::INVALID_KEYNAME;
 }
@@ -772,7 +772,7 @@ RegError ORegistry::closeKey(RegKeyHandle hKey)
 RegError ORegistry::deleteKey(RegKeyHandle hKey, const OUString& keyName)
 {
 ORegKey* pKey = static_cast< ORegKey* >(hKey);
-if ( keyName.isEmpty() )
+if (keyName.isEmpty())
 return RegError::INVALID_KEYNAME;
 
 REG_GUARD(m_mutex);
@@ -788,7 +788,7 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& 
keyName)
 {
 RegError _ret = RegError::NO_ERROR;
 
-if ( keyName.isEmpty() )
+if (keyName.isEmpty())
 {
 return RegError::INVALID_KEYNAME;
 }
@@ -798,7 +798,7 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& 
keyName)
 OUString sRelativKey;
 sal_Int32lastIndex = keyName.lastIndexOf('/');
 
-if ( lastIndex >= 0 )
+if (lastIndex >= 0)
 {
 sRelativKey += keyName.copy(lastIndex + 1);
 
@@ -836,7 +836,7 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& 
keyName)
 tmpName += ROOT;
 
 OStoreFile sFile(pKey->getStoreFile());
-if ( sFile.isValid() && sFile.remove(sFullPath, tmpName) )
+if (sFile.isValid() && sFile.remove(sFullPath, tmpN

[Libreoffice-commits] core.git: registry/source

2017-05-26 Thread Chris Sherlock
 registry/source/regimpl.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b6536a2ff0f9ea9ad431eeba2c8b5493823dd21b
Author: Chris Sherlock 
Date:   Sat May 27 00:07:34 2017 +1000

registry: typo in function parameter

Change-Id: I0a0e9551e427f3ca0fe15a5eec05f85e852642fe
Reviewed-on: https://gerrit.libreoffice.org/38075
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx
index b375318f359f..8d9ed6185d91 100644
--- a/registry/source/regimpl.hxx
+++ b/registry/source/regimpl.hxx
@@ -75,7 +75,7 @@ public:
 
 RegErrorloadKey(RegKeyHandle hKey,
 const OUString& regFileName,
-bool bWarings,
+bool bWarnings,
 bool bReport);
 
 RegErrordumpRegistry(RegKeyHandle hKey) const;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2017-05-26 Thread Chris Sherlock
 registry/source/regimpl.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 94844e60fc7d57352333d78f10bd47fae8adf6f5
Author: Chris Sherlock 
Date:   Fri May 26 22:25:23 2017 +1000

tdf#39468: translate German to English in registry's regimpl.cxx

Change-Id: Ibda59217728c9c959c4648d73005770d27644b77
Reviewed-on: https://gerrit.libreoffice.org/38069
Reviewed-by: Michael Stahl 
Tested-by: Michael Stahl 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index aaf9f8f4f164..5499e7b5c7da 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1526,7 +1526,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, 
const OUString& sName, sal_
 stdout, "%lu = %ld\n",
 sal::static_int_cast< unsigned long >(i),
 sal::static_int_cast< long >(longValue));
-offset += 4; // 4 Bytes fuer sal_Int32
+offset += 4; // 4 Bytes for sal_Int32
 }
 }
 break;
@@ -1551,7 +1551,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, 
const OUString& sName, sal_
 {
 readUINT32(pBuffer+offset, sLen);
 
-offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des 
strings in Bytes
+offset += 4; // 4 bytes (sal_uInt32) for the string size
 
 sal_Char *pValue = 
static_cast(rtl_allocateMemory(sLen));
 readUtf8(pBuffer+offset, pValue, sLen);
@@ -1589,7 +1589,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, 
const OUString& sName, sal_
 {
 readUINT32(pBuffer+offset, sLen);
 
-offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des 
strings in Bytes
+offset += 4; // 4 bytes (sal_uInt32) for the string size
 
 sal_Unicode *pValue = 
static_cast(rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode)));
 readString(pBuffer+offset, pValue, sLen);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2017-02-25 Thread Stephan Bergmann
 registry/source/regimpl.cxx |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 0203b6be4bb397165d7c6c354e75409164a0e360
Author: Stephan Bergmann 
Date:   Sat Feb 25 10:14:05 2017 +0100

loplugin:loopvartoosmall

Change-Id: I8c2fcdbcfaa8ebf83a80fb99701096982b564ef1

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 0065b49..aaf9f8f 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1174,13 +1174,12 @@ static sal_uInt32 checkTypeReaders(RegistryTypeReader& 
reader1,
std::set< OUString >& nameSet)
 {
 sal_uInt32 count=0;
-sal_uInt16 i;
-for (i=0 ; i < reader1.getFieldCount(); i++)
+for (sal_uInt32 i=0 ; i < reader1.getFieldCount(); i++)
 {
 nameSet.insert(reader1.getFieldName(i));
 count++;
 }
-for (i=0 ; i < reader2.getFieldCount(); i++)
+for (sal_uInt32 i=0 ; i < reader2.getFieldCount(); i++)
 {
 if (nameSet.find(reader2.getFieldName(i)) == nameSet.end())
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2015-01-25 Thread Stephan Bergmann
 registry/source/reflread.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 643c46bbd69ae47d90327726a8348f589d2a487d
Author: Stephan Bergmann 
Date:   Sun Jan 25 20:13:03 2015 +0100

loplugin:unreffun

Change-Id: Id7e0ddf60e32a27cb3922ae6c64feeec40f8e079

diff --git a/registry/source/reflread.cxx b/registry/source/reflread.cxx
index 2905bd3..23f267d 100644
--- a/registry/source/reflread.cxx
+++ b/registry/source/reflread.cxx
@@ -821,8 +821,6 @@ public:
 }
 }
 
-sal_uInt32 parseIndex() { return ((m_numOfEntries ? sizeof(sal_uInt16) : 
0) + (m_numOfEntries * m_REFERENCE_ENTRY_SIZE));}
-
 const sal_Char* getReferenceName(sal_uInt16 index);
 RTReferenceType getReferenceType(sal_uInt16 index);
 const sal_Char* getReferenceDoku(sal_uInt16 index);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2014-11-21 Thread Stephan Bergmann
 registry/source/regimpl.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit e3d76b24e43b9e43580814523e8a1c60cbbca731
Author: Stephan Bergmann 
Date:   Fri Nov 21 12:35:11 2014 +0100

Silence unhelpful cid#1215304 untrusted loop bound warnings

Change-Id: If4db6a631ad6b24ca6ecfef81a0a20b766ed6324

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 3d44092..3781309 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -326,6 +326,8 @@ void dumpType(typereg::Reader const & reader, OString const 
& indent) {
 printf(
 "%sparameter count: %u\n", indent.getStr(),
 static_cast< unsigned int 
>(reader.getMethodParameterCount(i)));
+// coverity[tainted_data] cid#1215304 unhelpfully warns about an
+// untrusted loop bound here:
 for (sal_uInt16 j = 0; j < reader.getMethodParameterCount(i); ++j)
 {
 printf(
@@ -366,6 +368,8 @@ void dumpType(typereg::Reader const & reader, OString const 
& indent) {
 printf(
 "%sexception count: %u\n", indent.getStr(),
 static_cast< unsigned int 
>(reader.getMethodExceptionCount(i)));
+// coverity[tainted_data] cid#1215304 unhelpfully warns about an
+// untrusted loop bound here:
 for (sal_uInt16 j = 0; j < reader.getMethodExceptionCount(i); ++j)
 {
 printf(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2014-11-18 Thread Stephan Bergmann
 registry/source/reflread.cxx |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 24714f5eaa08016da3f8a74f4842b25eb37ad814
Author: Stephan Bergmann 
Date:   Tue Nov 18 11:18:04 2014 +0100

Fix memchr checks

(thanks caolan for spotting)

Change-Id: I17093b4173b9a2fca2760240375bcb14313224ef

diff --git a/registry/source/reflread.cxx b/registry/source/reflread.cxx
index e226fbf..838010c 100644
--- a/registry/source/reflread.cxx
+++ b/registry/source/reflread.cxx
@@ -363,7 +363,8 @@ const sal_Char* 
ConstantPool::readUTF8NameConstant(sal_uInt16 index)
 if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == 
CP_TAG_UTF8_NAME)
 {
 sal_uInt32 n = m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA;
-if (n < m_bufferLen && std::memchr(m_pBuffer, 0, n) != nullptr)
+if (n < m_bufferLen
+&& std::memchr(m_pBuffer + n, 0, m_bufferLen - n) != nullptr)
 {
 aName = (const sal_Char*) (m_pBuffer + n);
 }
@@ -564,7 +565,9 @@ const sal_Unicode* 
ConstantPool::readStringConstant(sal_uInt16 index)
 if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == 
CP_TAG_CONST_STRING)
 {
 sal_uInt32 n = m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA;
-if (n >= m_bufferLen || std::memchr(m_pBuffer, 0, n) == 
nullptr)
+if (n >= m_bufferLen
+|| (std::memchr(m_pBuffer + n, 0, m_bufferLen - n)
+== nullptr))
 {
 throw BoundsError();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2014-11-17 Thread Stephan Bergmann
 registry/source/reflcnst.hxx |   46 ---
 1 file changed, 46 deletions(-)

New commits:
commit 87c51f9b75198503633bc30f40b73f40a40fc72d
Author: Stephan Bergmann 
Date:   Mon Nov 17 17:20:35 2014 +0100

Remove dead code

Change-Id: I1edce9e336650cc3317de8883e08fb6536c58c70

diff --git a/registry/source/reflcnst.hxx b/registry/source/reflcnst.hxx
index e9e3944..e08da94 100644
--- a/registry/source/reflcnst.hxx
+++ b/registry/source/reflcnst.hxx
@@ -106,13 +106,6 @@ inline sal_uInt32 writeBYTE(sal_uInt8* buffer, sal_uInt8 v)
 return sizeof(sal_uInt8);
 }
 
-inline sal_uInt16 readBYTE(const sal_uInt8* buffer, sal_uInt8& v)
-{
-v = buffer[0];
-
-return sizeof(sal_uInt8);
-}
-
 inline sal_uInt32 writeINT16(sal_uInt8* buffer, sal_Int16 v)
 {
 buffer[0] = (sal_uInt8)((v >> 8) & 0xFF);
@@ -121,13 +114,6 @@ inline sal_uInt32 writeINT16(sal_uInt8* buffer, sal_Int16 
v)
 return sizeof(sal_Int16);
 }
 
-inline sal_uInt32 readINT16(const sal_uInt8* buffer, sal_Int16& v)
-{
-v = ((buffer[0] << 8) | (buffer[1] << 0));
-
-return sizeof(sal_Int16);
-}
-
 inline sal_uInt32 writeUINT16(sal_uInt8* buffer, sal_uInt16 v)
 {
 buffer[0] = (sal_uInt8)((v >> 8) & 0xFF);
@@ -206,22 +192,6 @@ inline sal_uInt32 writeINT64(sal_uInt8* buffer, sal_Int64 
v)
 return sizeof(sal_Int64);
 }
 
-inline sal_uInt32 readINT64(const sal_uInt8* buffer, sal_Int64& v)
-{
-v = (
-((sal_Int64)buffer[0] << 56) |
-((sal_Int64)buffer[1] << 48) |
-((sal_Int64)buffer[2] << 40) |
-((sal_Int64)buffer[3] << 32) |
-((sal_Int64)buffer[4] << 24) |
-((sal_Int64)buffer[5] << 16) |
-((sal_Int64)buffer[6] << 8)  |
-((sal_Int64)buffer[7] << 0)
-);
-
-return sizeof(sal_Int64);
-}
-
 inline sal_uInt32 writeUINT64(sal_uInt8* buffer, sal_uInt64 v)
 {
 buffer[0] = (sal_uInt8)((v >> 56) & 0xFF);
@@ -236,22 +206,6 @@ inline sal_uInt32 writeUINT64(sal_uInt8* buffer, 
sal_uInt64 v)
 return sizeof(sal_uInt64);
 }
 
-inline sal_uInt32 readUINT64(const sal_uInt8* buffer, sal_uInt64& v)
-{
-v = (
-((sal_uInt64)buffer[0] << 56) |
-((sal_uInt64)buffer[1] << 48) |
-((sal_uInt64)buffer[2] << 40) |
-((sal_uInt64)buffer[3] << 32) |
-((sal_uInt64)buffer[4] << 24) |
-((sal_uInt64)buffer[5] << 16) |
-((sal_uInt64)buffer[6] << 8)  |
-((sal_uInt64)buffer[7] << 0)
-);
-
-return sizeof(sal_uInt64);
-}
-
 inline sal_uInt32 writeUtf8(sal_uInt8* buffer, const sal_Char* v)
 {
 sal_uInt32 size = strlen(v) + 1;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2014-09-25 Thread Caolán McNamara
 registry/source/regimpl.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 81055f589fc2de92e37dbe29f59b5da80728b28a
Author: Caolán McNamara 
Date:   Thu Sep 25 16:39:51 2014 +0100

coverity#705672 Resource leak

Change-Id: Ibeab8e1b64f3185eaca81a31bd131d11994386f3
Signed-off-by: Stephan Bergmann 

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 7021f45..f043eef 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -541,11 +541,11 @@ RegError ORegistry::destroyRegistry(const OUString& 
regName)
 
 if (!regName.isEmpty())
 {
-ORegistry* pReg = new ORegistry();
+std::unique_ptr pReg(new ORegistry());
 
 if (!pReg->initRegistry(regName, REG_READWRITE))
 {
-delete pReg;
+pReg.reset();
 
 OUString systemName;
 if ( FileBase::getSystemPathFromFileURL(regName, systemName) != 
FileBase::E_None )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source

2014-07-04 Thread Norbert Thiebaud
 registry/source/keyimpl.cxx |   19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

New commits:
commit e18e2b174c6bcf8ed5c5a6d3c88e84f31f2f375a
Author: Norbert Thiebaud 
Date:   Fri Jul 4 20:30:59 2014 +0200

coverity#1213422 Tainted Scalar

Change-Id: I87e845f346fda225127e3439e768b31a8eb93be3

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index 38fa3bb..52c2642 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -707,6 +707,15 @@ RegError ORegKey::getLongListValue(const OUString& 
valueName, sal_Int32** pValue
 
 rtl_freeMemory(pBuffer);
 
+/* check for 'reasonable' value */
+/* surely 10 millions entry in a registry list should be enough */
+if(valueSize > 4000)
+{
+pValueList = NULL;
+*pLen = 0;
+rtl_freeMemory(pBuffer);
+return REG_INVALID_VALUE;
+}
 pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
 
 if ( rValue.readAt(VALUE_HEADEROFFSET, pBuffer, valueSize, readBytes) )
@@ -727,12 +736,20 @@ RegError ORegKey::getLongListValue(const OUString& 
valueName, sal_Int32** pValue
 sal_uInt32 len = 0;
 readUINT32(pBuffer, len);
 
+/* make sure the declared size of the arry is consistant with the amount 
of data we have read */
+if(len > (valueSize - 4) / 4)
+{
+pValueList = NULL;
+*pLen = 0;
+rtl_freeMemory(pBuffer);
+return REG_INVALID_VALUE;
+}
 *pLen = len;
 sal_Int32* pVList = (sal_Int32*)rtl_allocateZeroMemory(len * 
sizeof(sal_Int32));
 
 sal_uInt32 offset = 4; // initial 4 Bytes fuer die Laenge des Arrays;
 
-for (sal_uInt32 i=0; i < len; i++)
+for (sal_uInt32 i = 0; i < len; i++)
 {
 readINT32(pBuffer+offset, pVList[i]);
 offset += 4;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: registry/source registry/test

2014-02-26 Thread Alexander Wilms
 registry/source/keyimpl.cxx  |   80 +-
 registry/source/regimpl.cxx  |   88 ++--
 registry/source/registry.cxx |  100 +++---
 registry/source/regkey.cxx   |  188 +--
 registry/test/testmerge.cxx  |   10 +-
 registry/test/testregcpp.cxx |2 
 6 files changed, 234 insertions(+), 234 deletions(-)

New commits:
commit 75c8d59ddd6ca19ff312c8e507ef05d969704d5a
Author: Alexander Wilms 
Date:   Tue Feb 25 19:42:37 2014 +0100

Remove visual noise from registry

Change-Id: Ica0c7fe04dae3c52583cc2324bae1cfa5af1e197
Reviewed-on: https://gerrit.libreoffice.org/8292
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index 793427e..c8a3ddd 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -30,9 +30,9 @@ using namespace store;
 
 namespace { static char const VALUE_PREFIX[] = "$VL_"; }
 
-//*
+
 //  ORegKey()
-//
+
 ORegKey::ORegKey(const OUString& keyName, ORegistry* pReg)
 : m_refCount(1)
 , m_name(keyName)
@@ -42,43 +42,43 @@ ORegKey::ORegKey(const OUString& keyName, ORegistry* pReg)
 {
 }
 
-//*
+
 //  ~ORegKey()
-//
+
 ORegKey::~ORegKey()
 {
 OSL_POSTCOND(m_refCount == 0, "registry::ORegKey::dtor(): refcount not 
zero.");
 }
 
-//*
+
 //  releaseKey
-//
+
 RegError ORegKey::releaseKey(RegKeyHandle hKey)
 {
 return m_pRegistry->releaseKey(hKey);
 }
 
-//*
+
 //  createKey
-//
+
 RegError ORegKey::createKey(const OUString& keyName, RegKeyHandle* phNewKey)
 {
 return m_pRegistry->createKey(this, keyName, phNewKey);
 }
 
 
-//*
+
 //  openKey
-//
+
 RegError ORegKey::openKey(const OUString& keyName, RegKeyHandle* phOpenKey)
 {
 return m_pRegistry->openKey(this, keyName, phOpenKey);
 }
 
 
-//*
+
 //  openSubKeys
-//
+
 RegError ORegKey::openSubKeys(const OUString& keyName, RegKeyHandle** 
phOpenSubKeys, sal_uInt32* pnSubKeys)
 {
 RegError _ret = REG_NO_ERROR;
@@ -138,9 +138,9 @@ RegError ORegKey::openSubKeys(const OUString& keyName, 
RegKeyHandle** phOpenSubK
 }
 
 
-//*
+
 //  getKeyNames
-//
+
 RegError ORegKey::getKeyNames(const OUString& keyName,
   rtl_uString*** pSubKeyNames,
   sal_uInt32* pnSubKeys)
@@ -198,27 +198,27 @@ RegError ORegKey::getKeyNames(const OUString& keyName,
 }
 
 
-//*
+
 //  closeKey
-//
+
 RegError ORegKey::closeKey(RegKeyHandle hKey)
 {
 return (m_pRegistry->closeKey(hKey));
 }
 
 
-//*
+
 //  deleteKey
-//
+
 RegError ORegKey::deleteKey(const OUString& keyName)
 {
 return (m_pRegistry->deleteKey(this, keyName));
 }
 
 
-//*
+
 //  getValueType
-//
+
 RegError ORegKey::getValueInfo(const OUString& valueName, RegValueType* 
pValueType, sal_uInt32* pValueSize) const
 {
 OStoreStreamrValue;
@@ -283,9 +283,9 @@ RegError ORegKey::getValueInfo(const OUString& valueName, 
RegValueType* pValueTy
 }
 
 
-//*
+
 //  setValue
-//
+
 RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, 
RegValue value, sal_uInt32 vSize)
 {
 OStoreStreamrValue;
@@ -358,9 +358,9 @@ RegError ORegKey::setValue(const OUString& valueName, 
RegValueType vType, RegVal
 return REG_NO_ERROR;
 }
 
-//*
+
 //  setLongListValue
-//
+
 RegError ORegKey::setLongListValue(const OUString& valueName, sal_Int32* 
pValueList, sal_uInt32 len)
 {
 OStoreStreamrValue;
@@ -417,9 +417,9 @@ RegError ORegKey::setLongListValue(const OUString& 
valueName, sal_Int32* pValueL
 return REG_NO_ERROR;
 }
 
-//*
+
 //  setStringListValue
-//
+
 RegError ORegKey::setStringListValue(const OUString& valueName, sal_Char** 
pValueList, sal_uInt32 len)
 {
 OStoreStreamrValue;
@@ -485,9 +485,9 @@ RegError ORegKey::setStringListValue(const OUString& 
valueName, sal_Char** pValu
 return REG_NO_ERROR;
 }
 
-//*
+
 //  setUnicodeListValue
-//
+
 RegError ORegKey::setUnicodeListValue(const OUString& valueName, sal_Unicode** 
pValueList, sal_uInt32 len)
 {