[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/source

Michael Stahl mstahl at redhat.com
Tue May 27 04:38:22 PDT 2014


 sw/source/filter/ww8/ww8graf.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 5f80a1059b19355753ce7950f7f900f51b13c2f0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue May 27 13:27:37 2014 +0200

    fdo#77454: sw: ww8 import: add heuristic to ignore mangled crop values
    
    Older versions of OOo/LO would mangle negative crop values on round-trip
    of WW8, which now (since the drawing-layer does not ignore them) causes
    the images to be rendered invisible; probably large factors don't make
    sense anyway, so ignore the crop if it's 50x the image size, which
    happens to work for the bugdoc.
    
    Change-Id: I9f36d37e3be27234554bc91e80bfe719b1ce86af
    (cherry picked from commit 7e91dd0a3885ac561aee9cf7907632677b9886c1)

diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index ec4bf38..e03811f 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1975,8 +1975,14 @@ void SwWW8ImplReader::MapWrapIntoFlyFmt(SvxMSDffImportRec* pRecord,
 static sal_Int32 lcl_ConvertCrop(sal_uInt32 const nCrop, sal_Int32 const nSize)
 {
     // cast to sal_Int32 to handle negative crop properly
-    return ((static_cast<sal_Int32>(nCrop) >> 16) * nSize)
-              + (((nCrop & 0xffff) * nSize) >> 16) ;
+    sal_Int32 const nIntegral(static_cast<sal_Int32>(nCrop) >> 16);
+    // fdo#77454: heuristic to detect mangled values written by old OOo/LO
+    if (abs(nIntegral) >= 50) // FIXME: what's a good cut-off?
+    {
+        SAL_INFO("sw.ww8", "ignoring suspiciously large crop: " << nIntegral);
+        return 0;
+    }
+    return (nIntegral * nSize) + (((nCrop & 0xffff) * nSize) >> 16);
 }
 
 void


More information about the Libreoffice-commits mailing list