Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12812 FP variableScope with pointer to buffer #6540

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,9 @@ bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& us
}
}
}
const auto yield = astContainerYield(tok);
if (yield == Library::Container::Yield::BUFFER || yield == Library::Container::Yield::BUFFER_NT)
return false;
}
}

Expand Down
10 changes: 10 additions & 0 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5118,3 +5118,13 @@ void constParameterReference_insert(std::list<int>& l, int& r) {
l.insert(l.end(), r);
l.insert(l.end(), 5, r);
}

const char* variableScope_cstr_dummy(const char* q); // #12812
std::size_t variableScope_cstr(const char* p) {
std::string s;
if (!p) {
s = "abc";
p = variableScope_cstr_dummy(s.c_str());
}
return std::strlen(p);
}
Loading