From fd79973509458adfef5c26582fe66c1c48cc2110 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 6 Sep 2023 14:10:23 +0300 Subject: [PATCH] Fixed crash when importing custom theme with duplicated entries. --- .../window/themes/window_theme_editor_block.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp index 24a4b8e7d2..ac217b30b9 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp @@ -225,6 +225,10 @@ void EditorBlock::feed(const QString &name, QColor value, const QString ©OfE bool EditorBlock::feedCopy(const QString &name, const QString ©Of) { if (auto row = findRow(copyOf)) { + if (copyOf == name) { + LOG(("Theme Warning: Skipping value '%1: %2' (the value refers to itself.)").arg(name, copyOf)); + return true; + } if (findRow(name)) { // Remove the existing row and mark all its copies as unique keys. LOG(("Theme Warning: Color value '%1' appears more than once in the color scheme.").arg(name)); @@ -232,6 +236,10 @@ bool EditorBlock::feedCopy(const QString &name, const QString ©Of) { // row was invalidated by removeRow() call. row = findRow(copyOf); + // Should not happen, but still check. + if (!row) { + return true; + } } addRow(name, copyOf, row->value()); } else {