Commit 84b0ec82 authored by Christopher Davis's avatar Christopher Davis

media_viewer: Fix potential overflow when loading media viewer

The media viewer could panic if you loaded it quickly after
starting up the app when media_list.len() could return zero.
Now the length of media_viewer is insured to be greater than
zero before subtraction.
parent 2c9557f5
......@@ -212,7 +212,7 @@ impl Data {
previous_media_button.set_visible(true);
}
if self.current_media_index >= self.media_list.len() - 1 {
if self.media_list.len() > 0 && self.current_media_index >= self.media_list.len() - 1 {
next_media_button.set_visible(false);
} else {
next_media_button.set_visible(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment