Merge pull request #18309 from github/calumgrant/bmn/return-stack-allocated-memory

C++: Fix FPs to cpp/return-stack-allocated-memory
This commit is contained in:
Calum Grant
2024-12-20 10:54:24 +00:00
committed by GitHub
4 changed files with 24 additions and 1 deletions

View File

@@ -248,4 +248,5 @@ char* test_strdupa(const char* s) {
void* test_strndupa(const char* s, size_t size) {
char* s2 = strndupa(s, size);
return s2; // BAD
}
}

View File

@@ -0,0 +1,16 @@
// semmle-extractor-options: --expect_errors
UNKNOWN_TYPE test_error_value() {
UNKNOWN_TYPE x;
return x; // GOOD: Error return type
}
void* test_error_pointer() {
UNKNOWN_TYPE x;
return &x; // BAD [FALSE NEGATIVE]
}
int* test_error_pointer_member() {
UNKNOWN_TYPE x;
return &x.y; // BAD [FALSE NEGATIVE]
}