From: kgv Date: Fri, 11 Oct 2019 11:56:03 +0000 (+0300) Subject: 0031048: Visualization - runtime error reported by Clang undefined behavior sanitizer... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=e81e69db03ab8f5463e0a3d1e253346558ae1534;p=occt-copy.git 0031048: Visualization - runtime error reported by Clang undefined behavior sanitizer in Image_AlienPixMap::Save() Image_PixMapData - use unsigned math (uintptr_t) instead of signed math with pointers for defining negative stride. --- diff --git a/src/Image/Image_PixMapData.hxx b/src/Image/Image_PixMapData.hxx index ec870b1dd9..046bc1bc76 100644 --- a/src/Image/Image_PixMapData.hxx +++ b/src/Image/Image_PixMapData.hxx @@ -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.