Kaydet (Commit) 54ddc4ff authored tarafından Julien Nabet's avatar Julien Nabet

tdf#117446: FB mig, (VAR)BINARY, fix memory management

By default, 8000 bytes are allocated for VARBINARY
The pb is we can need more.
See https://bugs.documentfoundation.org/show_bug.cgi?id=117446#c6

Change-Id: I0ef5811dc01a587491bd9345129d1a41a4d9f095
Reviewed-on: https://gerrit.libreoffice.org/54863Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst 44391aec
...@@ -837,12 +837,19 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex, ...@@ -837,12 +837,19 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex,
setParameterNull(nParameterIndex, false); setParameterNull(nParameterIndex, false);
const sal_Int32 nMaxSize = 0xFFFF; const sal_Int32 nMaxSize = 0xFFFF;
Sequence<sal_Int8> xBytesCopy(xBytes); Sequence<sal_Int8> xBytesCopy(xBytes);
// First 2 bytes indicate string size
if (xBytesCopy.getLength() > nMaxSize) if (xBytesCopy.getLength() > nMaxSize)
{ {
xBytesCopy.realloc( nMaxSize ); xBytesCopy.realloc( nMaxSize );
} }
const short nSize = xBytesCopy.getLength(); const short nSize = xBytesCopy.getLength();
// 8000 corresponds to value from lcl_addDefaultParameters
// in dbaccess/source/filter/hsqldb/createparser.cxx
if (nSize > 8000)
{
free(pVar->sqldata);
pVar->sqldata = static_cast<char *>(malloc(sizeof(char) * nSize + 2));
}
// First 2 bytes indicate string size
memcpy(pVar->sqldata, &nSize, 2); memcpy(pVar->sqldata, &nSize, 2);
// Actual data // Actual data
memcpy(pVar->sqldata + 2, xBytesCopy.getConstArray(), nSize); memcpy(pVar->sqldata + 2, xBytesCopy.getConstArray(), nSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment