@@ -55,6 +55,8 @@ void Texture::Resize( const size_t width, const size_t height ) {
5555 if ( m_width != width || m_height != height ) {
5656
5757 // Log( "Setting texture size to " + std::to_string( width ) + "x" + std::to_string( height ) );
58+ ASSERT ( width < VERY_BIG_NUMBER, " texture width overflow" );
59+ ASSERT ( height < VERY_BIG_NUMBER, " texture height overflow" );
5860
5961 m_width = width;
6062 m_height = height;
@@ -158,6 +160,9 @@ void Texture::Fill( const size_t x1, const size_t y1, const size_t x2, const siz
158160void Texture::AddFrom ( const types::texture::Texture* source, add_flag_t flags, const size_t x1, const size_t y1, const size_t x2, const size_t y2, const size_t dest_x, const size_t dest_y, const rotate_t rotate, const float alpha, util::random::Random* rng, util::Perlin* perlin ) {
159161 ASSERT ( x2 >= x1, " invalid source x size ( " + std::to_string ( x2 ) + " < " + std::to_string ( x1 ) + " )" );
160162 ASSERT ( y2 >= y1, " invalid source y size ( " + std::to_string ( y2 ) + " < " + std::to_string ( y1 ) + " )" );
163+ ASSERT ( source, " source texture is null" );
164+ ASSERT ( x2 < source->m_width , " source x overflow ( " + std::to_string ( x2 ) + " >= " + std::to_string ( source->m_width ) + " )" );
165+ ASSERT ( y2 < source->m_height , " source y overflow ( " + std::to_string ( y2 ) + " >= " + std::to_string ( source->m_height ) + " )" );
161166 ASSERT ( dest_x + ( x2 - x1 ) < m_width, " destination x overflow ( " + std::to_string ( dest_x + ( x2 - x1 ) ) + " >= " + std::to_string ( m_width ) + " )" );
162167 ASSERT ( dest_y + ( y2 - y1 ) < m_height, " destination y overflow (" + std::to_string ( dest_y + ( y2 - y1 ) ) + " >= " + std::to_string ( m_height ) + " )" );
163168 ASSERT ( alpha >= 0 , " invalid alpha value ( " + std::to_string ( alpha ) + " < 0 )" );
@@ -177,8 +182,11 @@ void Texture::AddFrom( const types::texture::Texture* source, add_flag_t flags,
177182 const size_t w = x2 - x1 + 1;
178183 const size_t h = y2 - y1 + 1 ;
179184
180- const void * from;
181- void * to;
185+ ASSERT ( w > 0 , " w is zero" );
186+ ASSERT ( h > 0 , " h is zero" );
187+
188+ const void * from = nullptr ;
189+ void * to = nullptr ;
182190
183191 ASSERT ( rotate < 4 , " invalid rotate value " + std::to_string ( rotate ) );
184192 if ( rotate > 0 ) {
@@ -884,21 +892,28 @@ Texture* Texture::FromColor( const Color& color ) {
884892}
885893
886894void Texture::Update ( const updated_area_t updated_area ) {
887- // Log( "Need texture update [ "+ std::to_string( updated_area.left ) + " " + std::to_string( updated_area.top ) + " " + std::to_string( updated_area.right ) + " " + std::to_string( updated_area.bottom ) + " ]" );
895+ // Log( "Need texture update [ " + std::to_string( updated_area.left ) + " " + std::to_string( updated_area.top ) + " " + std::to_string( updated_area.right ) + " " + std::to_string( updated_area.bottom ) + " ]" );
896+ ASSERT ( updated_area.right > updated_area.left && updated_area.right < VERY_BIG_NUMBER, " invalid area right" );
897+ ASSERT ( updated_area.bottom > updated_area.top && updated_area.bottom < VERY_BIG_NUMBER, " invalid area right" );
888898 m_updated_areas.push_back ( updated_area );
889899 m_update_counter++;
890900}
891901
892902void Texture::FullUpdate () {
893903 ClearUpdatedAreas ();
894- Update (
895- {
896- 0 ,
897- 0 ,
898- m_width,
899- m_height
900- }
901- );
904+ if ( m_width > 0 && m_height > 0 ) {
905+ Update (
906+ {
907+ 0 ,
908+ 0 ,
909+ m_width,
910+ m_height
911+ }
912+ );
913+ }
914+ else {
915+ m_update_counter++;
916+ }
902917}
903918
904919const size_t Texture::UpdatedCount () const {
0 commit comments