Adds zero size check in Fl_Tile::on_move

This commit is contained in:
Matthias Melcher 2023-11-23 00:03:35 +01:00
parent 8041a62e59
commit de2dd0cddf

View File

@ -706,8 +706,9 @@ int Fl_Tile::on_move(int oldIndex, int newIndex) {
*/ */
void Fl_Tile::on_remove(int index) { void Fl_Tile::on_remove(int index) {
if (size_range_) { if (size_range_) {
if ((index >= 0) && (index < size_range_size_)) int num_trailing = size_range_size_-index-1;
memmove(size_range_+index, size_range_+index+1, sizeof(Size_Range)*(size_range_size_-index-1)); if ((index >= 0) && (index < size_range_size_) && (num_trailing > 0))
memmove(size_range_+index, size_range_+index+1, sizeof(Size_Range)*num_trailing);
size_range_size_--; size_range_size_--;
} }
} }