Skip to content

Commit 508020e

Browse files
committed
Add explicit destructor calls and exclude RAII calls
1 parent 234ca96 commit 508020e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

cpp/misra/src/rules/RULE-21-6-1/DynamicMemoryShouldNotBeUsed.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,11 @@ where
266266

267267
(
268268
call.getTarget() instanceof DynamicMemoryDeallocatingFunction and
269-
// not call.isCompilerGenerated() // Exclude RAII constructor calls.
270-
exists(Expr expr | expr != call.getAnImplicitDestructorCall())
269+
(
270+
call instanceof DestructorCall implies not call.isCompilerGenerated() // Exclude RAII constructor calls.
271+
)
271272
) and
272-
not call.getTarget() instanceof DynamicMemoryAllocatingFunction and
273+
not call.getTarget() instanceof DynamicMemoryAllocatingFunction and // Exclude `realloc`.
273274
message = "Call to '" + call.getTarget().getName() + "' that dynamically deallocates memory."
274275
)
275-
select call, message
276+
select call, message

0 commit comments

Comments
 (0)