File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
test/query-tests/jsf/4.10 Classes/AV Rule 79 Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,21 @@ class Resource extends MemberVariable {
125125
126126 private Assignment getANew ( ) {
127127 result .getLValue ( ) = this .getAnAccess ( ) and
128- ( result .getRValue ( ) instanceof NewExpr or result .getRValue ( ) instanceof NewArrayExpr ) and
128+ (
129+ (
130+ result .getRValue ( ) instanceof NewExpr and
131+
132+ // exclude placement new and custom overloads as they
133+ // may not conform to assumptions
134+ not result .getRValue ( ) .( NewExpr ) .getAllocatorCall ( ) .getTarget ( ) .getNumberOfParameters ( ) > 1
135+ ) or (
136+ result .getRValue ( ) instanceof NewArrayExpr and
137+
138+ // exclude placement new and custom overloads as they
139+ // may not conform to assumptions
140+ not result .getRValue ( ) .( NewArrayExpr ) .getAllocatorCall ( ) .getTarget ( ) .getNumberOfParameters ( ) > 1
141+ )
142+ ) and
129143 this .inSameClass ( result )
130144 }
131145
Original file line number Diff line number Diff line change 1212| ListDelete.cpp:21:3:21:21 | ... = ... | Resource first is acquired by class MyThingColection but not released anywhere in this class. |
1313| NoDestructor.cpp:23:3:23:20 | ... = ... | Resource n is acquired by class MyClass5 but not released anywhere in this class. |
1414| PlacementNew.cpp:36:3:36:36 | ... = ... | Resource p1 is acquired by class MyTestForPlacementNew but not released anywhere in this class. |
15- | PlacementNew.cpp:37:3:37:51 | ... = ... | Resource p2 is acquired by class MyTestForPlacementNew but not released anywhere in this class. |
16- | PlacementNew.cpp:38:3:38:49 | ... = ... | Resource p3 is acquired by class MyTestForPlacementNew but not released anywhere in this class. |
1715| SelfRegistering.cpp:25:3:25:24 | ... = ... | Resource side is acquired by class MyOwner but not released anywhere in this class. |
1816| Variants.cpp:23:3:23:13 | ... = ... | Resource f is acquired by class MyClass4 but not released anywhere in this class. |
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ class MyTestForPlacementNew
3434 void *buffer_ptr = buffer;
3535
3636 p1 = new MyClassForPlacementNew (1 ); // BAD: not released
37- p2 = new (std::nothrow) MyClassForPlacementNew (2 ); // BAD: not released
38- p3 = new (buffer_ptr) MyClassForPlacementNew (3 ); // GOOD: placement new, not an allocation [FALSE POSITIVE]
37+ p2 = new (std::nothrow) MyClassForPlacementNew (2 ); // BAD: not released [NOT DETECTED]
38+ p3 = new (buffer_ptr) MyClassForPlacementNew (3 ); // GOOD: placement new, not an allocation
3939 }
4040
4141 ~MyTestForPlacementNew ()
You can’t perform that action at this time.
0 commit comments