[vlc-commits] qt: fix possible invalid access in PlayerControlBar

Prince Gupta git at videolan.org
Mon Mar 15 10:33:03 UTC 2021


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Wed Feb 10 20:22:33 2021 +0530| [db2ccc02a6b93ee0eeb4be147b1cc1af7f5ed97f] | committer: Pierre Lamot

qt: fix possible invalid access in PlayerControlBar

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=db2ccc02a6b93ee0eeb4be147b1cc1af7f5ed97f
---

 modules/gui/qt/player/playercontrolbarmodel.cpp | 39 ++++++++++++++-----------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/modules/gui/qt/player/playercontrolbarmodel.cpp b/modules/gui/qt/player/playercontrolbarmodel.cpp
index 28ed1ed1a6..6aa486cfa5 100644
--- a/modules/gui/qt/player/playercontrolbarmodel.cpp
+++ b/modules/gui/qt/player/playercontrolbarmodel.cpp
@@ -113,24 +113,29 @@ void PlayerControlBarModel::reloadModel()
         parseAndAdd(config.toString());
     else
     {
-        QString alignment = configName.split("-").at(1);
-        if (configName.startsWith("MainPlayerToolbar"))
+        const auto configAndAlignment = configName.split("-");
+        if (configAndAlignment.size() == 2)
         {
-            if (alignment == "left")
-                parseDefault(MAIN_TB_DEFAULT[default_align::ALIGN_LEFT]);
-            else if (alignment == "center")
-                parseDefault(MAIN_TB_DEFAULT[default_align::ALIGN_CENTER]);
-            else if (alignment == "right")
-                parseDefault(MAIN_TB_DEFAULT[default_align::ALIGN_RIGHT]);
-        }
-        else
-        {
-            if (alignment == "left")
-                parseDefault(MINI_TB_DEFAULT[default_align::ALIGN_LEFT]);
-            else if (alignment == "center")
-                parseDefault(MINI_TB_DEFAULT[default_align::ALIGN_CENTER]);
-            else if (alignment == "right")
-                parseDefault(MINI_TB_DEFAULT[default_align::ALIGN_RIGHT]);
+            const auto alignment = configAndAlignment[1];
+            if (configAndAlignment[0] == QLatin1String("MainPlayerToolbar"))
+            {
+                if (alignment == "left")
+                    parseDefault(MAIN_TB_DEFAULT[default_align::ALIGN_LEFT]);
+                else if (alignment == "center")
+                    parseDefault(MAIN_TB_DEFAULT[default_align::ALIGN_CENTER]);
+                else if (alignment == "right")
+                    parseDefault(MAIN_TB_DEFAULT[default_align::ALIGN_RIGHT]);
+            }
+            else
+            {
+                if (alignment == "left")
+                    parseDefault(MINI_TB_DEFAULT[default_align::ALIGN_LEFT]);
+                else if (alignment == "center")
+                    parseDefault(MINI_TB_DEFAULT[default_align::ALIGN_CENTER]);
+                else if (alignment == "right")
+                    parseDefault(MINI_TB_DEFAULT[default_align::ALIGN_RIGHT]);
+
+            }
         }
     }
     endResetModel();



More information about the vlc-commits mailing list