forked from OSchip/llvm-project
[analyzer] Add test for a crash fixed in r338775.
Do not crash if a CXXRecordDecl cannot be obtained for an object. Special thanks for the reproduction to Alexander Kornienko. llvm-svn: 338918
This commit is contained in:
parent
4dfe279e00
commit
bfd9cfdeeb
|
@ -133,10 +133,7 @@ bool InnerPointerChecker::isCalledOnStringObject(
|
|||
return false;
|
||||
|
||||
CXXRecordDecl *Decl = ObjTy->getAsCXXRecordDecl();
|
||||
if (!Decl || Decl->getName() != "basic_string")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return Decl && Decl->getName() == "basic_string";
|
||||
}
|
||||
|
||||
bool InnerPointerChecker::isInvalidatingMemberFunction(
|
||||
|
|
|
@ -382,3 +382,13 @@ const char *escape_via_return_local() {
|
|||
// expected-note@-1 {{Inner pointer invalidated by call to destructor}}
|
||||
} // expected-warning {{Use of memory after it is freed}}
|
||||
// expected-note@-1 {{Use of memory after it is freed}}
|
||||
|
||||
|
||||
char *c();
|
||||
class A {};
|
||||
|
||||
void no_CXXRecordDecl() {
|
||||
A a, *b;
|
||||
*(void **)&b = c() + 1;
|
||||
*b = a; // no-crash
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue