Skip to content

Commit 787fb4c

Browse files
committed
consider increment operator
1 parent 188fd30 commit 787fb4c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

c/cert/src/rules/ENV30-C/DoNotModifyTheReturnValueOfCertainFunctions.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Expr objectModified(NotModifiableCall c) {
4545
ae.getRValue().(FunctionCall).getArgument(0).getValue() = ["0", "3", "4"]
4646
)
4747
)
48+
or
49+
exists(CrementOperation co | result = co.getOperand())
4850
}
4951

5052
/**

c/cert/test/rules/ENV30-C/DoNotModifyTheReturnValueOfCertainFunctions.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ subpaths
7474
| test.c:21:9:21:12 | env1 | test.c:5:18:5:22 | c_str | test.c:5:18:5:22 | c_str | test.c:21:9:21:12 | ref arg env1 |
7575
#select
7676
| test.c:8:7:8:12 | * ... | test.c:15:16:15:21 | call to getenv | test.c:8:7:8:12 | * ... | The object returned by the function getenv should no be modified. |
77+
| test.c:10:7:10:11 | c_str | test.c:15:16:15:21 | call to getenv | test.c:10:7:10:11 | c_str | The object returned by the function getenv should no be modified. |
7778
| test.c:63:5:63:9 | conv4 | test.c:60:11:60:19 | call to setlocale | test.c:63:5:63:9 | conv4 | The object returned by the function setlocale should no be modified. |

c/cert/test/rules/ENV30-C/test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
void trstr(char *c_str, char orig, char rep) {
66
while (*c_str != '\0') {
77
if (*c_str == orig) {
8-
*c_str = rep;
8+
*c_str = rep; // NON_COMPLIANT
99
}
10-
++c_str;
10+
++c_str; // NON_COMPLIANT
1111
}
1212
}
1313

@@ -18,7 +18,7 @@ void f1(void) {
1818

1919
if (env1 == NULL) {
2020
}
21-
trstr(env1, '"', '_'); // NON_COMPLIANT
21+
trstr(env1, '"', '_');
2222
}
2323

2424
void f2(void) {

0 commit comments

Comments
 (0)