Skip to content

Commit

Permalink
Fix #12812 FP variableScope with pointer to buffer (#6540)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Jun 21, 2024
1 parent da6b55e commit 199418d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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);
}

0 comments on commit 199418d

Please sign in to comment.