Browse Source

image-source: Fix crash when randomize with 0 files

Chris (Flaeri) 1 year ago
parent
commit
0c2f3f8049
1 changed files with 6 additions and 1 deletions
  1. 6 1
      plugins/image-source/obs-slideshow-mk2.c

+ 6 - 1
plugins/image-source/obs-slideshow-mk2.c

@@ -377,7 +377,12 @@ static struct source_data get_new_source(struct slideshow *ss,
 static void restart_slides(struct slideshow *ss)
 {
 	struct slideshow_data *ssd = &ss->data;
-	size_t start_idx = ssd->randomize ? (size_t)rand() % ssd->files.num : 0;
+	size_t start_idx = 0;
+
+	if (ssd->randomize && ssd->files.num > 0) {
+		start_idx = (size_t)rand() % ssd->files.num;
+	}
+
 	struct active_slides new_slides = {0};
 
 	if (ssd->files.num) {