Skip to content

Commit 922d0e5

Browse files
author
Nikita Kraiouchkine
committed
Revert CloseFileHandleWhenNoLongerNeededShared.qll change
1 parent 2b1ebfe commit 922d0e5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cpp/common/src/codingstandards/cpp/rules/closefilehandlewhennolongerneededshared/CloseFileHandleWhenNoLongerNeededShared.qll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ import semmle.code.cpp.controlflow.StackVariableReachability
1010
import codingstandards.cpp.standardlibrary.FileAccess
1111
import codingstandards.cpp.Allocations
1212

13+
/**
14+
* Extend the NullValue class used by Nullness.qll to include simple -1 as a 'null' value
15+
* (for example 'open' returns -1 if there was an error)
16+
*/
17+
class MinusOne extends NullValue {
18+
MinusOne() { this.(UnaryMinusExpr).getOperand().(Literal).getValue() = "1" }
19+
}
20+
1321
/**
1422
* 'call' is either a direct call to f, or a possible call to f
1523
* via a function pointer.
@@ -22,7 +30,7 @@ predicate mayCallFunction(Expr call, Function f) {
2230

2331
predicate fopenCallOrIndirect(Expr e) {
2432
// direct allocation call
25-
allocExpr(e, _) and
33+
opened(e) and
2634
// We are only interested in allocation calls that are
2735
// actually freed somehow, as MemoryNeverFreed
2836
// will catch those that aren't.

0 commit comments

Comments
 (0)