diff --git a/src/layout/segmented.c b/src/layout/segmented.c index 3477bf4c..98afe708 100644 --- a/src/layout/segmented.c +++ b/src/layout/segmented.c @@ -203,13 +203,23 @@ fail: } void free_layout_segmented(segmented_layout_data *data) { - int i; + int i, j; if (!data) return; if (data->segments) { for (i = 0; i < data->segment_count; i++) { + int is_repeat = 0; + + /* segments are allowed to be repeated so don't close the same thing twice */ + for (j = 0; j < i; j++) { + if (data->segments[i] == data->segments[j]) + is_repeat = 1; + } + if (is_repeat) + continue; + close_vgmstream(data->segments[i]); } free(data->segments);