]> OCCT Git - occt-copy.git/commitdiff
0031048: Visualization - runtime error reported by Clang undefined behavior sanitizer...
authorkgv <kgv@opencascade.com>
Fri, 11 Oct 2019 11:56:03 +0000 (14:56 +0300)
committerkgv <kgv@opencascade.com>
Sat, 19 Oct 2019 12:52:23 +0000 (15:52 +0300)
Image_PixMapData - use unsigned math (uintptr_t) instead of signed math with pointers for defining negative stride.

src/Image/Image_PixMapData.hxx

index ec870b1dd93cc5ed26178486a70c90ac2b20d638..046bc1bc76f184488f72b9f631829bfa2816cf2e 100644 (file)
@@ -74,27 +74,27 @@ public:
   //! @return data pointer to requested row (first column).
   inline const Standard_Byte* Row (const Standard_Size theRow) const
   {
-    return myTopRowPtr + SizeRowBytes * theRow * TopToDown;
+    return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown);
   }
 
   //! @return data pointer to requested row (first column).
   inline Standard_Byte* ChangeRow (const Standard_Size theRow)
   {
-    return myTopRowPtr + SizeRowBytes * theRow * TopToDown;
+    return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown);
   }
 
   //! @return data pointer to requested position.
   inline const Standard_Byte* Value (const Standard_Size theRow,
                                      const Standard_Size theCol) const
   {
-    return myTopRowPtr + SizeRowBytes * theRow * TopToDown + SizeBPP * theCol;
+    return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown) + SizeBPP * theCol;
   }
 
   //! @return data pointer to requested position.
   inline Standard_Byte* ChangeValue (const Standard_Size theRow,
                                      const Standard_Size theCol)
   {
-    return myTopRowPtr + SizeRowBytes * theRow * TopToDown + SizeBPP * theCol;
+    return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown) + SizeBPP * theCol;
   }
 
   //! Compute the maximal row alignment for current row size.