From 04c25ed29d5ad146c1724a52d7b8318abdca4c04 Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Mon, 4 Sep 2017 03:52:25 -0500 Subject: [PATCH] common: Fix isChannelName crash on empty string Add check to isChannelName for an empty string; return false if so and don't try to index it. This avoids crashing on connect for some situations. Closes GH-307. --- src/common/util.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/util.cpp b/src/common/util.cpp index 3d199a12..a59db8fe 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -64,6 +64,8 @@ QString hostFromMask(const QString &mask) bool isChannelName(const QString &str) { + if (str.isEmpty()) + return false; static constexpr std::array prefixes{{'#', '&', '!', '+'}}; return std::any_of(prefixes.cbegin(), prefixes.cend(), [&str](quint8 c) { return c == str[0]; }); } -- 2.20.1