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

Tamás Bunth btomi96 at gmail.com
Wed Jan 11 17:48:32 UTC 2017


 connectivity/source/drivers/firebird/Blob.cxx |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 38ce989b4f9d2aead097e5a2e95b819def7e2624
Author: Tamás Bunth <btomi96 at gmail.com>
Date:   Tue Jan 10 15:16:08 2017 +0100

    XBlob::getBytes expects 1-indexed position
    
    There was also a wrong relation. Now blob resets its position.
    
    Change-Id: I41caf7cdfa261cafa5b9e66c9523c7f15225bfd8
    Reviewed-on: https://gerrit.libreoffice.org/32937
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
    Tested-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx
index 7a7481b..2c6b952 100644
--- a/connectivity/source/drivers/firebird/Blob.cxx
+++ b/connectivity/source/drivers/firebird/Blob.cxx
@@ -149,19 +149,20 @@ uno::Sequence< sal_Int8 > SAL_CALL  Blob::getBytes(sal_Int64 nPosition,
     checkDisposed(Blob_BASE::rBHelper.bDisposed);
     ensureBlobIsOpened();
 
-    if (nPosition > m_nBlobLength)
+    if (nPosition > m_nBlobLength || nPosition < 1)
         throw lang::IllegalArgumentException("nPosition out of range", *this, 0);
     // We only have to read as many bytes as are available, i.e. nPosition+nBytes
     // can legally be greater than the total length, hence we don't bother to check.
 
-    if (nPosition > m_nBlobPosition)
+    if (nPosition -1 < m_nBlobPosition)
     {
         // Resets to the beginning (we can't seek these blobs)
         closeBlob();
         ensureBlobIsOpened();
     }
 
-    skipBytes(nPosition - m_nBlobPosition);
+    // nPosition is indexed from 1.
+    skipBytes(nPosition - m_nBlobPosition -1 );
 
     // Don't bother preallocating: readBytes does the appropriate calculations
     // and reallocates for us.


More information about the Libreoffice-commits mailing list