mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
`SubtitleFormat`'s `LoadSubtitle()` function is not thread-safe. A `SubtitleEditParser` instance's `Parse()` function can be called from multiple threads at the same time. `SubtitleFormat`s are cached in the constructor of each `SubtitleEditParser`, and the same instances are used for each possibly parallel `Parse()` function call, which causes subtitle parse problems. This patch modifies the code, so we only cache the extension -> `SubtitleFormat` type/class mapping and create a new `SubtitleFormat` instance in each `Parse()` call, so no `SubtitleFormat` instance is accessed from multiple threads. Fixes #12113 Kudos for everyone investigating the issue there, most notably @RenV123 for PoC-ing the solution. Signed-off-by: Attila Szakacs <szakacs.attila96@gmail.com>