summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-04-01 19:40:21 +0200
committerAndras Timar <andras.timar@collabora.com>2022-04-06 14:00:13 +0200
commitefdecb54292ecfdeb798de21098e2098df8d003c (patch)
treeb15d7e264113e3968fc47d517084b668fa72831f /connectivity
parent2b4566aac2bfbcc118e4832e2b8814d9dc259fc9 (diff)
tdf#148310: Firebird: copy complete rows, CLOB field, last character lost
off by 1 pb. Indeed we got: 610 sal_Int64 nCharWritten = 1; // XClob is indexed from 1 offapi/com/sun/star/sdbc/XClob.idl indeed indicates: 114 The substring begins at position <code>pos</code> and has up 115 to 116 <code>length</code> 117 consecutive characters. 118 </p> 119 @param pos 120 the starting position, 1-based 121 @param length 122 the length of the substring 123 @returns 124 the substring 125 @throws SQLException 126 if a database access error occurs. 127 */ 128 string getSubString([in]hyper pos, [in]long length) raises (SQLException); but if the string to copy has length 1, we never enter: while ( nLen > nCharWritten ) => we must change this into: while ( nLen >= nCharWritten ) also number of remaining characters to take into account at each loop must be adapted too: sal_Int64 nCharRemain = nLen - nCharWritten; => would be 0 into: sal_Int64 nCharRemain = nLen - nCharWritten + 1; Change-Id: I7697c8312024818f73a19c39f694cf209f494d71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132443 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr> (cherry picked from commit da81a880df76bebb6d9fbc770c313381a3c33268) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132378 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/PreparedStatement.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index a3abf2d68cc8..392785b9c816 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -612,9 +612,9 @@ void SAL_CALL OPreparedStatement::setClob(sal_Int32 nParameterIndex, const Refer
sal_Int64 nCharWritten = 1; // XClob is indexed from 1
ISC_STATUS aErr = 0;
sal_Int64 nLen = xClob->length();
- while ( nLen > nCharWritten )
+ while ( nLen >= nCharWritten )
{
- sal_Int64 nCharRemain = nLen - nCharWritten;
+ sal_Int64 nCharRemain = nLen - nCharWritten + 1;
constexpr sal_uInt16 MAX_SIZE = SAL_MAX_UINT16 / 4;
sal_uInt16 nWriteSize = std::min<sal_Int64>(nCharRemain, MAX_SIZE);
OString sData = OUStringToOString(