mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-25 01:20:04 +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())
|
if (removeEmpty && s.empty())
|
||||||
continue;
|
continue;
|
||||||
if (++idx == lastArgNo) {
|
if (++idx == lastArgNo) {
|
||||||
m_args.emplace_back(trim(in.substr(pos)));
|
m_args.emplace_back(trim(std::string_view{m_str}.substr(pos)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pos += s.size() + 1;
|
pos += s.size() + 1;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,10 @@ int main(int argc, char** argv, char** envp) {
|
||||||
EXPECT(listConst[0], "hello");
|
EXPECT(listConst[0], "hello");
|
||||||
EXPECT(listConst[1], "world!");
|
EXPECT(listConst[1], "world!");
|
||||||
|
|
||||||
|
CConstVarList listConst2("0 set", 2, ' ');
|
||||||
|
EXPECT(listConst2[0], "0");
|
||||||
|
EXPECT(listConst2[1], "set");
|
||||||
|
|
||||||
std::string hello = "hello world!";
|
std::string hello = "hello world!";
|
||||||
replaceInString(hello, "hello", "hi");
|
replaceInString(hello, "hello", "hi");
|
||||||
EXPECT(hello, "hi world!");
|
EXPECT(hello, "hi world!");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue