summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2018-04-28 12:33:11 +0200
committerTamás Bunth <btomi96@gmail.com>2018-05-02 11:12:18 +0200
commit9123711dd092139fb95be92f3ff0cdde657086dd (patch)
tree9fc0bc40cb6294a4dac9d34ece79a677dc19564f
parente606179d5722427bc4137838585b38892e01b328 (diff)
tdf#117296 dbahsql: Fix migration of numeric
Change-Id: I9ca181c58cd73432c632147870d546d277893fdf Reviewed-on: https://gerrit.libreoffice.org/53587 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Bunth <btomi96@gmail.com>
-rw-r--r--dbaccess/source/filter/hsqldb/rowinputbinary.cxx11
1 files changed, 4 insertions, 7 deletions
diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index a2c736d9b5ac..62c37525367d 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -42,9 +42,8 @@ namespace
OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
{
size_t nbits = 8 * bytes.size(); // length of array in bits
- size_t nscratch = nbits / 3; // length of scratch in bytes
+ size_t nscratch = nbits / 2; // length of scratch in bytes
std::vector<char> scratch(nscratch, 0);
- size_t smin = nscratch - 2; // speed optimization
for (size_t i = 0; i < bytes.size(); ++i)
{
@@ -54,13 +53,11 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
int shifted_in = (bytes[i] & (1 << (7 - j))) ? 1 : 0;
/* Add 3 everywhere that scratch[k] >= 5. */
- for (size_t k = smin; k < nscratch; ++k)
+ for (size_t k = 0; k < nscratch; ++k)
scratch[k] += (scratch[k] >= 5) ? 3 : 0;
/* Shift scratch to the left by one position. */
- if (scratch[smin] >= 8)
- smin -= 1;
- for (size_t k = smin; k < nscratch - 1; ++k)
+ for (size_t k = 0; k < nscratch - 1; ++k)
{
scratch[k] <<= 1;
scratch[k] &= 0xF;
@@ -76,7 +73,7 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
auto it = scratch.begin();
/* Remove leading zeros from the scratch space. */
- while (*it == 0)
+ while (*it == 0 && scratch.size() > 1)
{
it = scratch.erase(it);
}