]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix incorrect std::string::operator[] usage
authorAttila Molnar <attilamolnar@hush.com>
Mon, 28 Sep 2015 08:36:17 +0000 (10:36 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 28 Sep 2015 08:36:17 +0000 (10:36 +0200)
Passing a position equal to length() to the non-const version of operator[] is undefined

src/modules/m_check.cpp
src/modules/m_namedmodes.cpp

index 9c5c414f195473386d4b7bf2b2ad95061a694d10..5063368b81506e023fff508298071b3c516bea81 100644 (file)
@@ -174,7 +174,7 @@ class CommandCheck : public Command
                        /* /check on a channel */
                        user->SendText(checkstr + " timestamp " + timestring(targchan->age));
 
-                       if (targchan->topic[0] != 0)
+                       if (!targchan->topic.empty())
                        {
                                /* there is a topic, assume topic related information exists */
                                user->SendText(checkstr + " topic " + targchan->topic);
index 4db1f70b92c78e9a0d5da781f99c0114a0eec90e..cad18cff48b586456018efcf88664d6be04d524e 100644 (file)
@@ -65,6 +65,8 @@ class CommandProp : public Command
                while (i < parameters.size())
                {
                        std::string prop = parameters[i++];
+                       if (prop.empty())
+                               continue;
                        bool plus = prop[0] != '-';
                        if (prop[0] == '+' || prop[0] == '-')
                                prop.erase(prop.begin());