Skip to content

Commit 199418d

Browse files
Fix #12812 FP variableScope with pointer to buffer (#6540)
1 parent da6b55e commit 199418d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/checkother.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,9 @@ bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& us
11491149
}
11501150
}
11511151
}
1152+
const auto yield = astContainerYield(tok);
1153+
if (yield == Library::Container::Yield::BUFFER || yield == Library::Container::Yield::BUFFER_NT)
1154+
return false;
11521155
}
11531156
}
11541157

test/cfg/std.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5118,3 +5118,13 @@ void constParameterReference_insert(std::list<int>& l, int& r) {
51185118
l.insert(l.end(), r);
51195119
l.insert(l.end(), 5, r);
51205120
}
5121+
5122+
const char* variableScope_cstr_dummy(const char* q); // #12812
5123+
std::size_t variableScope_cstr(const char* p) {
5124+
std::string s;
5125+
if (!p) {
5126+
s = "abc";
5127+
p = variableScope_cstr_dummy(s.c_str());
5128+
}
5129+
return std::strlen(p);
5130+
}

0 commit comments

Comments
 (0)