From bbb1f9e6d38d12efc4e030faf0b95a2d3a32080b Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Tue, 26 May 2026 17:48:49 +0200 Subject: [PATCH] MT#61856 media_player: add cached file func, name ownership issue The `name` is caller-owned, while the cache itself also keeps a separate key object in the `media_player_media_files_names`. This can desynchronize the hash key and the list key. Hence prefer using the owned key instead. Change-Id: I9b85c306cc4e2c32675bada3dec0d049ff5645fe (cherry picked from commit 7a4feef1ffdc44e6ff84e85bd2c3bed865164f5a) --- daemon/media_player.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/media_player.c b/daemon/media_player.c index dc9c45e74..a99b77fc2 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -2274,8 +2274,9 @@ bool media_player_add_cached_file(str *name) { LOCK(&media_player_media_files_lock); __auto_type foold = t_hash_table_lookup(media_player_media_files, name); if (foold) { + str *key = foold->str_link->data; fonew->str_link = foold->str_link; - t_hash_table_replace(media_player_media_files, name, fonew); + t_hash_table_replace(media_player_media_files, key, fonew); obj_put(foold); } else