src/lib/CDRPath.cpp |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 5da3e01b9aa19f8676e052e98815b861311222b9
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed May 29 18:41:01 2019 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Tue Jul 2 11:07:33 2019 +0200

    Avoid UB converting from double to int via unsigned
    
    See <https://gerrit.libreoffice.org/#/c/73181/> "external/libcdr: Avoid UB
    converting from double to int via unsigned" for details.
    
    Change-Id: I667dbca60674c183b0b7bee50deb0324becd6b21
    Reviewed-on: https://gerrit.libreoffice.org/73182
    Reviewed-by: Michael Stahl <michael.st...@cib.de>
    Tested-by: Michael Stahl <michael.st...@cib.de>

diff --git a/src/lib/CDRPath.cpp b/src/lib/CDRPath.cpp
index 86ee10c..cb45f67 100644
--- a/src/lib/CDRPath.cpp
+++ b/src/lib/CDRPath.cpp
@@ -796,7 +796,7 @@ void CDRPath::writeOut(librevenge::RVNGString &path, 
librevenge::RVNGString &vie
 
 
   width = qy - py;
-  viewBox.sprintf("%i %i %i %i", 0, 0, (unsigned)(2540*(qx - px)), 
(unsigned)(2540*(qy - py)));
+  viewBox.sprintf("%i %i %i %i", 0, 0, (int)(2540*(qx - px)), (int)(2540*(qy - 
py)));
 
   for (unsigned long i = 0; i < vec.count(); ++i)
   {
@@ -804,38 +804,38 @@ void CDRPath::writeOut(librevenge::RVNGString &path, 
librevenge::RVNGString &vie
     if (vec[i]["librevenge:path-action"]->getStr() == "M")
     {
       // 2540 is 2.54*1000, 2.54 in = 1 inch
-      sElement.sprintf("M%i %i", 
(unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
+      sElement.sprintf("M%i %i", (int)((vec[i]["svg:x"]->getDouble()-px)*2540),
+                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
       path.append(sElement);
     }
     else if (vec[i]["librevenge:path-action"]->getStr() == "L")
     {
-      sElement.sprintf("L%i %i", 
(unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
+      sElement.sprintf("L%i %i", (int)((vec[i]["svg:x"]->getDouble()-px)*2540),
+                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
       path.append(sElement);
     }
     else if (vec[i]["librevenge:path-action"]->getStr() == "C")
     {
-      sElement.sprintf("C%i %i %i %i %i %i", 
(unsigned)((vec[i]["svg:x1"]->getDouble()-px)*2540),
-                       (unsigned)((vec[i]["svg:y1"]->getDouble()-py)*2540), 
(unsigned)((vec[i]["svg:x2"]->getDouble()-px)*2540),
-                       (unsigned)((vec[i]["svg:y2"]->getDouble()-py)*2540), 
(unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
+      sElement.sprintf("C%i %i %i %i %i %i", 
(int)((vec[i]["svg:x1"]->getDouble()-px)*2540),
+                       (int)((vec[i]["svg:y1"]->getDouble()-py)*2540), 
(int)((vec[i]["svg:x2"]->getDouble()-px)*2540),
+                       (int)((vec[i]["svg:y2"]->getDouble()-py)*2540), 
(int)((vec[i]["svg:x"]->getDouble()-px)*2540),
+                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
       path.append(sElement);
     }
     else if (vec[i]["librevenge:path-action"]->getStr() == "Q")
     {
-      sElement.sprintf("Q%i %i %i %i", 
(unsigned)((vec[i]["svg:x1"]->getDouble()-px)*2540),
-                       (unsigned)((vec[i]["svg:y1"]->getDouble()-py)*2540), 
(unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
+      sElement.sprintf("Q%i %i %i %i", 
(int)((vec[i]["svg:x1"]->getDouble()-px)*2540),
+                       (int)((vec[i]["svg:y1"]->getDouble()-py)*2540), 
(int)((vec[i]["svg:x"]->getDouble()-px)*2540),
+                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
       path.append(sElement);
     }
     else if (vec[i]["librevenge:path-action"]->getStr() == "A")
     {
-      sElement.sprintf("A%i %i %i %i %i %i %i", 
(unsigned)((vec[i]["svg:rx"]->getDouble())*2540),
-                       (unsigned)((vec[i]["svg:ry"]->getDouble())*2540), 
(vec[i]["librevenge:rotate"] ? vec[i]["librevenge:rotate"]->getInt() : 0),
+      sElement.sprintf("A%i %i %i %i %i %i %i", 
(int)((vec[i]["svg:rx"]->getDouble())*2540),
+                       (int)((vec[i]["svg:ry"]->getDouble())*2540), 
(vec[i]["librevenge:rotate"] ? vec[i]["librevenge:rotate"]->getInt() : 0),
                        (vec[i]["librevenge:large-arc"] ? 
vec[i]["librevenge:large-arc"]->getInt() : 1),
                        (vec[i]["librevenge:sweep"] ? 
vec[i]["librevenge:sweep"]->getInt() : 1),
-                       (unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540), 
(unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
+                       (int)((vec[i]["svg:x"]->getDouble()-px)*2540), 
(int)((vec[i]["svg:y"]->getDouble()-py)*2540));
       path.append(sElement);
     }
     else if (vec[i]["librevenge:path-action"]->getStr() == "Z")
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to