0
0
forked from blender/blender
Files
blender/build_files/build_environment/patches/oiio_3996.diff
Brecht Van Lommel cd89390b52 Build: update 3.6 libraries to address CVEs and bugs
And ignore a few CVEs that do not affect Blender.

openimageio 2.4.15
openssl 3.1.2
python 3.10.13
sndfile 1.2.2
webp 1.3.2

Ref #104895

Co-authored-by: Ray Molenkamp <github@lazydodo.com>
Pull Request: blender/blender#112528
2023-10-09 14:24:37 +02:00

30 lines
1.1 KiB
Diff

diff --git a/src/include/OpenImageIO/fmath.h b/src/include/OpenImageIO/fmath.h
index 0bd71ba9b..419e5e378 100644
--- a/src/include/OpenImageIO/fmath.h
+++ b/src/include/OpenImageIO/fmath.h
@@ -1229,6 +1229,7 @@ convert_type (const S &src)
/// shifted fully to the right.
template<unsigned int FROM_BITS, unsigned int TO_BITS>
inline OIIO_HOSTDEVICE unsigned int bit_range_convert(unsigned int in) {
+ static_assert(FROM_BITS > 0, "FROM_BITS cannot be 0");
unsigned int out = 0;
int shift = TO_BITS - FROM_BITS;
for (; shift > 0; shift -= FROM_BITS)
@@ -1244,10 +1245,12 @@ inline OIIO_HOSTDEVICE unsigned int
bit_range_convert(unsigned int in, unsigned int FROM_BITS, unsigned int TO_BITS)
{
unsigned int out = 0;
- int shift = TO_BITS - FROM_BITS;
- for (; shift > 0; shift -= FROM_BITS)
- out |= in << shift;
- out |= in >> -shift;
+ if (FROM_BITS) {
+ int shift = TO_BITS - FROM_BITS;
+ for (; shift > 0; shift -= FROM_BITS)
+ out |= in << shift;
+ out |= in >> -shift;
+ }
return out;
}