Pārlūkot izejas kodu

libobs: Fix memory leak when migrating from legacy scene item data

Before the commit 763dddbbaf, hotkeys to show and hide scene items are
distinguished by source name instead of ID. When migrating from the
legacy data structure, the pointer to the data was not released.

(cherry picked from commit 9391ab305e04444cf66b8fde583b78a2ff071b57)
Norihiro Kamae 1 gadu atpakaļ
vecāks
revīzija
929520afde
1 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 6 2
      libobs/obs-scene.c

+ 6 - 2
libobs/obs-scene.c

@@ -2042,13 +2042,17 @@ static void init_hotkeys(obs_scene_t *scene, obs_sceneitem_t *item,
 	/* Check if legacy keys exists, migrate if necessary */
 	dstr_printf(&legacy, "libobs.show_scene_item.%s", name);
 	hotkey_array = obs_data_get_array(hotkey_data, legacy.array);
-	if (hotkey_array)
+	if (hotkey_array) {
 		obs_data_set_array(hotkey_data, show.array, hotkey_array);
+		obs_data_array_release(hotkey_array);
+	}
 
 	dstr_printf(&legacy, "libobs.hide_scene_item.%s", name);
 	hotkey_array = obs_data_get_array(hotkey_data, legacy.array);
-	if (hotkey_array)
+	if (hotkey_array) {
 		obs_data_set_array(hotkey_data, hide.array, hotkey_array);
+		obs_data_array_release(hotkey_array);
+	}
 
 	item->toggle_visibility = obs_hotkey_pair_register_source(
 		scene->source, show.array, show_desc.array, hide.array,