mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 04:40:08 +01:00
string/constVarList: fix UAF
This commit is contained in:
parent
164a30b3d8
commit
9637961a55
2 changed files with 5 additions and 1 deletions
|
|
@ -33,7 +33,7 @@ CConstVarList::CConstVarList(const std::string& in, const size_t lastArgNo, cons
|
|||
if (removeEmpty && s.empty())
|
||||
continue;
|
||||
if (++idx == lastArgNo) {
|
||||
m_args.emplace_back(trim(in.substr(pos)));
|
||||
m_args.emplace_back(trim(std::string_view{m_str}.substr(pos)));
|
||||
break;
|
||||
}
|
||||
pos += s.size() + 1;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ int main(int argc, char** argv, char** envp) {
|
|||
EXPECT(listConst[0], "hello");
|
||||
EXPECT(listConst[1], "world!");
|
||||
|
||||
CConstVarList listConst2("0 set", 2, ' ');
|
||||
EXPECT(listConst2[0], "0");
|
||||
EXPECT(listConst2[1], "set");
|
||||
|
||||
std::string hello = "hello world!";
|
||||
replaceInString(hello, "hello", "hi");
|
||||
EXPECT(hello, "hi world!");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue