From: Shane Synan Date: Mon, 4 Sep 2017 08:52:25 +0000 (-0500) Subject: common: Fix isChannelName crash on empty string X-Git-Tag: travis-deploy-test~257 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=04c25ed29d5ad146c1724a52d7b8318abdca4c04;hp=0fa9ff5b58bf321654204867bb118a8d727d7b16 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. --- 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]; }); }