From 93f305b9243a5fb608296a5fcf4466196b24d3cb Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Fri, 3 Nov 2023 14:34:12 -0500 Subject: [PATCH] Make sure metadata.map does not mutate existing metadata. --- CHANGES.md | 1 + src/core/operators/map_metadata.ml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6c00562825..d0656c675a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ Fixed: number of channels. - Improved support for unitary minus, fix runtime call of optional methods (#3498) +- Fixed `map.metadata` mutating existing metadata. - Fixed reloading loop in playlists with invalid files (#3479) - Fixed main HLS playlist codecs when using `mpegts` (#3483) - Fixed pop/clicks in crossfade and source with caching (#3318) diff --git a/src/core/operators/map_metadata.ml b/src/core/operators/map_metadata.ml index 7a9c3492a6..d74bbaa10f 100644 --- a/src/core/operators/map_metadata.ml +++ b/src/core/operators/map_metadata.ml @@ -63,8 +63,10 @@ class map_metadata source rewrite_f insert_missing update strip = List.iter (fun (t, m) -> if t >= p then ( + let m = Hashtbl.copy m in self#rewrite m; - if strip && Hashtbl.length m = 0 then Frame.free_metadata buf t)) + if strip && Hashtbl.length m = 0 then Frame.free_metadata buf t + else Frame.set_metadata buf t m)) (Frame.get_all_metadata buf) end