Open tanguimorvan opened 1 year ago
Index: channel_algorithm.hpp
===================================================================
--- channel_algorithm.hpp (revision 56209)
+++ channel_algorithm.hpp (working copy)
@@ -237,7 +237,7 @@
struct channel_converter_unsigned_integral_nondivisible<SrcChannelV,DstChannelV,true,false> {
DstChannelV operator()(SrcChannelV src) const {
typedef typename base_channel_type<DstChannelV>::type dest_t;
- return DstChannelV(static_cast<dest_t>( src * unsigned_integral_max_value<DstChannelV>::value) / unsigned_integral_max_value<SrcChannelV>::value);
+ return DstChannelV(static_cast<dest_t>( src ) * unsigned_integral_max_value<DstChannelV>::value / unsigned_integral_max_value<SrcChannelV>::value);
}
};
@tanguimorvan Thanks, feel free to open PR with your changes
Actual behavior
Channel conversion from boost::gil::packed_channel_value to uint16_t fails due to integer overflow in channel_converter_unsigned_integral_nondivisible<SrcChannelV,DstChannelV,true,false> .
Expected behavior
The value should not overflow, producing correct results.
C++ Minimal Working Example
Environment
<boost/version.hpp>
): 1.68 but seems to still be present in latest version.