Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a84163

Browse files
committed
C++: Fix false positive
1 parent faa9d83 commit 9a84163

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

cpp/ql/src/Likely Bugs/Likely Typos/AssignWhereCompareMeant.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class BooleanControllingAssignmentInStmt extends BooleanControllingAssignment {
6565
*/
6666
predicate candidateResult(BooleanControllingAssignment ae) {
6767
ae.getRValue().isConstant() and
68-
not ae.isWhitelisted()
68+
not ae.isWhitelisted() and
69+
not ae.getRValue() instanceof StringLiteral
6970
}
7071

7172
/**

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/AssignWhereCompareMeant/AssignWhereCompareMeant.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
| test.cpp:84:7:84:11 | ... = ... | Use of '=' where '==' may have been intended. |
1515
| test.cpp:92:17:92:22 | ... = ... | Use of '=' where '==' may have been intended. |
1616
| test.cpp:113:6:113:10 | ... = ... | Use of '=' where '==' may have been intended. |
17-
| test.cpp:124:6:124:15 | ... = ... | Use of '=' where '==' may have been intended. |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/AssignWhereCompareMeant/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@ void f() {
121121
void f2() {
122122
const char* sz = "abc";
123123

124-
if(sz = "def") { // GOOD [FALSE POSITIVE]: a == comparison with a string literal is probably not the intent here
124+
if(sz = "def") { // GOOD: a == comparison with a string literal is probably not the intent here
125125
}
126126
}

0 commit comments

Comments
 (0)