Description: Stay within bounds
 This patch fixes CVE-2017-15923.
Author: Eli MacKenzie <argonel@gmail.com>
Origin: upstream
Bug: https://www.kde.org/info/security/advisory-20171112-1.txt
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1731797
Applied-Upstream: 6a7f59ee1b9dbc6e5cf9e5f3b306504d02b73ef0
Reviewed-by: Eike Hein <hein@kde.org>
Last-Update: 2017-11-12
--- a/src/viewer/ircview.cpp
+++ b/src/viewer/ircview.cpp
@@ -1637,7 +1637,8 @@ QString IRCView::closeToTagString(TextHt
     }
 
     // reopen relevant tags
-    ret += openTags(data, i);
+    if (i > -1)
+        ret += openTags(data, i);
 
     return ret;
 }
@@ -1645,7 +1646,8 @@ QString IRCView::closeToTagString(TextHt
 QString IRCView::openTags(TextHtmlData* data, int from)
 {
     QString ret, tag;
-    int i = from;
+    int i = from > -1 ? from : 0;
+
     for ( ;  i < data->openHtmlTags.count(); ++i)
     {
         tag = data->openHtmlTags.at(i);
