parent
824672b445
commit
02d32318c8
@ -0,0 +1,57 @@
|
||||
From fd94964ad6611d7f20523272fe6752d38e3aec88 Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Mon, 14 Dec 2015 21:17:43 +0100
|
||||
Subject: [PATCH] don't be creative and use a simple lookup table
|
||||
|
||||
The original code breaks at least in optimized build on Fedora x86,
|
||||
because there nBits for 256 is computed as 9, not 8.
|
||||
|
||||
Change-Id: Ib157c415bc9e231bf7fd544349810e6bc83c8fcc
|
||||
---
|
||||
oox/source/ole/vbaexport.cxx | 23 +++++++++++++++++++++--
|
||||
1 file changed, 21 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
|
||||
index 2cb2fea..2041d50 100644
|
||||
--- a/oox/source/ole/vbaexport.cxx
|
||||
+++ b/oox/source/ole/vbaexport.cxx
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
+#include <cassert>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
|
||||
@@ -324,8 +325,26 @@ void VBACompressionChunk::CopyTokenHelp(sal_uInt16& rLengthMask, sal_uInt16& rOf
|
||||
sal_uInt16& rBitCount, sal_uInt16& rMaximumLength)
|
||||
{
|
||||
sal_uInt16 nDifference = mnDecompressedCurrent;
|
||||
- sal_uInt16 nBitCount = std::ceil(std::log(nDifference)/std::log(2));
|
||||
- rBitCount = std::max<sal_uInt16>(nBitCount, 4);
|
||||
+ assert(nDifference <= 4096);
|
||||
+ assert(nDifference >= 1);
|
||||
+ if (nDifference >= 2049)
|
||||
+ rBitCount = 12;
|
||||
+ else if (nDifference >= 1025)
|
||||
+ rBitCount = 11;
|
||||
+ else if (nDifference >= 513)
|
||||
+ rBitCount = 10;
|
||||
+ else if (nDifference >= 257)
|
||||
+ rBitCount = 9;
|
||||
+ else if (nDifference >= 129)
|
||||
+ rBitCount = 8;
|
||||
+ else if (nDifference >= 65)
|
||||
+ rBitCount = 7;
|
||||
+ else if (nDifference >= 33)
|
||||
+ rBitCount = 6;
|
||||
+ else if (nDifference >= 17)
|
||||
+ rBitCount = 5;
|
||||
+ else
|
||||
+ rBitCount = 4;
|
||||
rLengthMask = 0xffff >> rBitCount;
|
||||
rOffsetMask = ~rLengthMask;
|
||||
rMaximumLength = rLengthMask + 3;
|
||||
--
|
||||
2.5.0
|
||||
|
Loading…
Reference in new issue