diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-09-23 02:51:16 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-09-23 03:16:58 +0200 |
commit | 83c7cc45daf6fb1f8c36f15297a4657e45a34e88 (patch) | |
tree | c29ad7d8623eb7789c39c519de19ee414db2a95e /src/users.cpp | |
parent | cff57f7ba780a5c4fc331ccbab489abdc572379c (diff) |
Fix undefined behavior caused by referencing the returned buffer by std::string::c_str() when the object is temporary
Thanks to @ChrisTX for pointing this out
Fixes #257 reported by @helloall
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/users.cpp b/src/users.cpp index f211f6b49..a4af8914b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -633,7 +633,8 @@ void OperInfo::init() AllowedPrivs.insert(mypriv); } - for (unsigned char* c = (unsigned char*)tag->getString("usermodes").c_str(); *c; ++c) + std::string modes = tag->getString("usermodes"); + for (std::string::const_iterator c = modes.begin(); c != modes.end(); ++c) { if (*c == '*') { @@ -645,7 +646,8 @@ void OperInfo::init() } } - for (unsigned char* c = (unsigned char*)tag->getString("chanmodes").c_str(); *c; ++c) + modes = tag->getString("chanmodes"); + for (std::string::const_iterator c = modes.begin(); c != modes.end(); ++c) { if (*c == '*') { |