From 0c312ec6681eed35f7247a8c52c95cfe10172c53 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Tue, 24 Jan 2023 20:23:46 +0100 Subject: [PATCH 1/4] libvisual: Fix heap-use-after-free on pallete when switching actors --- libvisual/libvisual/lv_bin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libvisual/libvisual/lv_bin.c b/libvisual/libvisual/lv_bin.c index cef1294db..111a7b7a3 100644 --- a/libvisual/libvisual/lv_bin.c +++ b/libvisual/libvisual/lv_bin.c @@ -693,6 +693,7 @@ int visual_bin_switch_finalize (VisBin *bin) visual_log (VISUAL_LOG_DEBUG, "Entering..."); if (bin->managed == TRUE) visual_object_unref (VISUAL_OBJECT (bin->actor)); + visual_video_set_palette (bin->actvideo, NULL); /* Copy over the depth to be sure, and for GL plugins */ /* bin->actvideo->depth = bin->actmorphvideo->depth; From 33cbab745d83637abc7f77789f3a32dd44a85001 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sat, 28 Jan 2023 04:10:46 +0100 Subject: [PATCH 2/4] libvisual: Fix code path that misses setting the video palette --- libvisual/libvisual/lv_bin.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libvisual/libvisual/lv_bin.c b/libvisual/libvisual/lv_bin.c index 111a7b7a3..2af308ff7 100644 --- a/libvisual/libvisual/lv_bin.c +++ b/libvisual/libvisual/lv_bin.c @@ -852,6 +852,8 @@ int visual_bin_run (VisBin *bin) visual_bin_switch_finalize (bin); + visual_video_set_palette (bin->actvideo, visual_actor_get_palette (bin->actor)); + /* We can't start drawing yet, the client needs to catch up with * the depth change */ return 0; From dfec9fef85a712d4688dbb44397310c5f90cb509 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sat, 28 Jan 2023 04:17:27 +0100 Subject: [PATCH 3/4] lv-tool: Apply a full palette every time the palette changes and only then --- libvisual/tools/lv-tool/lv-tool.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libvisual/tools/lv-tool/lv-tool.cpp b/libvisual/tools/lv-tool/lv-tool.cpp index 4ce9c25fa..f23f1c2f4 100644 --- a/libvisual/tools/lv-tool/lv-tool.cpp +++ b/libvisual/tools/lv-tool/lv-tool.cpp @@ -28,6 +28,8 @@ #include "gettext.h" #include #include +#include +#include #include #include #include @@ -412,21 +414,29 @@ namespace { void update_all() { visual_log_return_if_fail( m_screen != nullptr ); + static VisPalette * prev_pal = nullptr; if (m_screen->format->BitsPerPixel == 8) { visual_log_return_if_fail( m_screen_video != nullptr ); VisPalette * const pal = m_screen_video->pal; - if (pal != nullptr && pal->ncolors >= 256) { - SDL_Color colors[256]; - - for (int i = 0; i < 256; i++) { - colors[i].r = pal->colors[i].r; - colors[i].g = pal->colors[i].g; - colors[i].b = pal->colors[i].b; + if (pal != prev_pal) { + std::array colors {}; + + if (pal) { + const std::size_t source_color_count = std::min(colors.size(), + static_cast(pal->ncolors)); + for (std::size_t i = 0; i < source_color_count; i++) { + colors[i].r = pal->colors[i].r; + colors[i].g = pal->colors[i].g; + colors[i].b = pal->colors[i].b; + } } - SDL_SetColors (m_screen, colors, 0, 256); + SDL_SetColors (m_screen, colors.data(), 0, colors.size()); + prev_pal = pal; } + } else { + prev_pal = nullptr; } if (m_requested_depth == VISUAL_VIDEO_DEPTH_GL) { From 981b9a244c8a0770e2bd90939b133464a4a77391 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 6 Feb 2023 03:03:34 +0100 Subject: [PATCH 4/4] libvisual: Sync translation --- libvisual/po/de.po | 8 ++++---- libvisual/po/es_AR.po | 8 ++++---- libvisual/po/es_ES.po | 8 ++++---- libvisual/po/libvisual-0.4.pot | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libvisual/po/de.po b/libvisual/po/de.po index 116dbcad8..daa74c3ed 100644 --- a/libvisual/po/de.po +++ b/libvisual/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libvisual 0.4.0-2.2\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-05 06:13+0100\n" +"POT-Creation-Date: 2023-02-06 03:03+0100\n" "PO-Revision-Date: 2017-08-10 18:46+GMT\n" "Last-Translator: Chris Leick \n" "Language-Team: German \n" @@ -188,11 +188,11 @@ msgstr "" msgid "depth of the main actor: %d" msgstr "Tiefe des Hauptdarstellers: %d" -#: libvisual/lv_bin.c:739 +#: libvisual/lv_bin.c:740 msgid "negotiate without event" msgstr "handeln ohne Ereignis" -#: libvisual/lv_bin.c:741 +#: libvisual/lv_bin.c:742 msgid "end negotiate without event" msgstr "handeln ohne Ereignis beenden" @@ -900,7 +900,7 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "Ungültige Tiefe an Scaler übergeben" -#: tools/lv-tool/lv-tool.cpp:882 tools/lv-tool/lv-tool.cpp:1063 +#: tools/lv-tool/lv-tool.cpp:892 tools/lv-tool/lv-tool.cpp:1073 msgid "lv-tool" msgstr "" diff --git a/libvisual/po/es_AR.po b/libvisual/po/es_AR.po index ed283ed9b..2c7652801 100644 --- a/libvisual/po/es_AR.po +++ b/libvisual/po/es_AR.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Libvisual Library 0.4.0\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-05 06:13+0100\n" +"POT-Creation-Date: 2023-02-06 03:03+0100\n" "PO-Revision-Date: 2005-03-20 17:09-0300\n" "Last-Translator: \n" "Language-Team: Spanish\n" @@ -186,11 +186,11 @@ msgstr "fin de cambio de actor por nombre ******************" msgid "depth of the main actor: %d" msgstr "profundidad para el actor principal: %d" -#: libvisual/lv_bin.c:739 +#: libvisual/lv_bin.c:740 msgid "negotiate without event" msgstr "negociando sin evento" -#: libvisual/lv_bin.c:741 +#: libvisual/lv_bin.c:742 msgid "end negotiate without event" msgstr "fin de negociación sin evento" @@ -918,7 +918,7 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "Profundidad pasada al escalador inválida" -#: tools/lv-tool/lv-tool.cpp:882 tools/lv-tool/lv-tool.cpp:1063 +#: tools/lv-tool/lv-tool.cpp:892 tools/lv-tool/lv-tool.cpp:1073 msgid "lv-tool" msgstr "" diff --git a/libvisual/po/es_ES.po b/libvisual/po/es_ES.po index 65d5f93c2..59b1530ac 100644 --- a/libvisual/po/es_ES.po +++ b/libvisual/po/es_ES.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Libvisual Library 0.4.0\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-05 06:13+0100\n" +"POT-Creation-Date: 2023-02-06 03:03+0100\n" "PO-Revision-Date: 2005-03-20 17:09-0300\n" "Last-Translator: \n" "Language-Team: Spanish\n" @@ -186,11 +186,11 @@ msgstr "fin de cambio de actor por nombre ******************" msgid "depth of the main actor: %d" msgstr "profundidad para el actor principal: %d" -#: libvisual/lv_bin.c:739 +#: libvisual/lv_bin.c:740 msgid "negotiate without event" msgstr "negociando sin evento" -#: libvisual/lv_bin.c:741 +#: libvisual/lv_bin.c:742 msgid "end negotiate without event" msgstr "fin de negociación sin evento" @@ -918,7 +918,7 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "Profundidad pasada al escalador inválida" -#: tools/lv-tool/lv-tool.cpp:882 tools/lv-tool/lv-tool.cpp:1063 +#: tools/lv-tool/lv-tool.cpp:892 tools/lv-tool/lv-tool.cpp:1073 msgid "lv-tool" msgstr "" diff --git a/libvisual/po/libvisual-0.4.pot b/libvisual/po/libvisual-0.4.pot index c11feda68..0139c4c40 100644 --- a/libvisual/po/libvisual-0.4.pot +++ b/libvisual/po/libvisual-0.4.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: libvisual 0.4.1\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-05 06:13+0100\n" +"POT-Creation-Date: 2023-02-06 03:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -186,11 +186,11 @@ msgstr "" msgid "depth of the main actor: %d" msgstr "" -#: libvisual/lv_bin.c:739 +#: libvisual/lv_bin.c:740 msgid "negotiate without event" msgstr "" -#: libvisual/lv_bin.c:741 +#: libvisual/lv_bin.c:742 msgid "end negotiate without event" msgstr "" @@ -871,6 +871,6 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "" -#: tools/lv-tool/lv-tool.cpp:882 tools/lv-tool/lv-tool.cpp:1063 +#: tools/lv-tool/lv-tool.cpp:892 tools/lv-tool/lv-tool.cpp:1073 msgid "lv-tool" msgstr ""