Skip to content

Commit

Permalink
C++: Fix FPs to cpp/return-stack-allocated-memory
Browse files Browse the repository at this point in the history
  • Loading branch information
calumgrant committed Dec 17, 2024
1 parent 8efd870 commit 14cef6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class ReturnStackAllocatedMemoryConfig extends MustFlowConfiguration {
or
node2.(PointerOffsetInstruction).getLeftOperand() = node1
}

override predicate isBarrier(Instruction n) { n.getResultType() instanceof ErroneousType }
}

from
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// semmle-extractor-options: -std=c++14
// semmle-extractor-options: -std=c++14 --expect_errors
class MyClass
{
public:
Expand Down Expand Up @@ -248,4 +248,9 @@ char* test_strdupa(const char* s) {
void* test_strndupa(const char* s, size_t size) {
char* s2 = strndupa(s, size);
return s2; // BAD
}
}

UNKNOWN_TYPE test_error_type() {
UNKNOWN_TYPE x;
return x; // GOOD: Don't report error types
}

0 comments on commit 14cef6a

Please sign in to comment.