Skip to content

Commit

Permalink
pieimage.cpp: Additional sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Nov 16, 2023
1 parent 232a703 commit 4b01f52
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ivis_opengl/pieimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ bool iV_Image::convert_channels(const std::vector<unsigned int>& channelMap)
ASSERT_OR_RETURN(false, channelMap.size() <= 4, "iV_Image does not support > 4 channel textures (channelMap has %zu entries)", channelMap.size());
auto originalChannels = m_channels;
ASSERT_OR_RETURN(false, std::all_of(channelMap.begin(), channelMap.end(), [originalChannels](unsigned int srcChannel){ return srcChannel < originalChannels; }), "Channel swizzle contains channel > originalChannels (%u)", m_channels);
ASSERT_OR_RETURN(false, m_width > 0 && m_height > 0, "No size");

unsigned int newChannels = static_cast<unsigned int>(channelMap.size());

Expand All @@ -440,6 +441,7 @@ bool iV_Image::convert_channels(const std::vector<unsigned int>& channelMap)
bool iV_Image::convert_to_single_channel(unsigned int channel /*= 0*/)
{
ASSERT_OR_RETURN(false, channel < m_channels, "Cannot extract channel %u from image with %u channels", channel, m_channels);
ASSERT_OR_RETURN(false, m_width > 0 && m_height > 0, "No size");
if (channel == 0 && m_channels == 1)
{
// nothing to do
Expand Down

0 comments on commit 4b01f52

Please sign in to comment.