From 096cb1625f150999231d23cb0b2950abbd60dc88 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 07:06:27 -0700 Subject: [PATCH] fix: sanitizer new warnings about signed/unsigned offsets in openexr (#4351) Signed-off-by: Larry Gritz --- src/openexr.imageio/exrinput.cpp | 3 ++- src/openexr.imageio/exroutput.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openexr.imageio/exrinput.cpp b/src/openexr.imageio/exrinput.cpp index 2adb03cbdd..2085ada3a4 100644 --- a/src/openexr.imageio/exrinput.cpp +++ b/src/openexr.imageio/exrinput.cpp @@ -1140,7 +1140,8 @@ OpenEXRInput::read_native_scanlines(int subimage, int miplevel, int ybegin, const PartInfo& part(m_parts[m_subimage]); size_t pixelbytes = m_spec.pixel_bytes(chbegin, chend, true); size_t scanlinebytes = (size_t)m_spec.width * pixelbytes; - char* buf = (char*)data - m_spec.x * pixelbytes - ybegin * scanlinebytes; + char* buf = (char*)data - m_spec.x * stride_t(pixelbytes) + - ybegin * stride_t(scanlinebytes); try { if (part.luminance_chroma) { diff --git a/src/openexr.imageio/exroutput.cpp b/src/openexr.imageio/exroutput.cpp index 0820834d8c..e89cb0a528 100644 --- a/src/openexr.imageio/exroutput.cpp +++ b/src/openexr.imageio/exroutput.cpp @@ -1508,7 +1508,8 @@ OpenEXROutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format, // the bytes to be written, but OpenEXR's frameBuffer.insert() wants // where the address of the "virtual framebuffer" for the whole // image. - char* buf = (char*)d - m_spec.x * pixel_bytes - y * scanlinebytes; + char* buf = (char*)d - m_spec.x * stride_t(pixel_bytes) + - y * stride_t(scanlinebytes); try { Imf::FrameBuffer frameBuffer; size_t chanoffset = 0;