Skip to content

Commit d3576b9

Browse files
committed
C++: Accept test changes.
1 parent 56d7342 commit d3576b9

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
| test.cpp:29:13:29:24 | call to operator new[] | memory allocation error check is incorrect or missing |
2-
| test.cpp:37:13:37:24 | call to operator new[] | memory allocation error check is incorrect or missing |
3-
| test.cpp:41:13:41:24 | call to operator new[] | memory allocation error check is incorrect or missing |
4-
| test.cpp:49:8:49:19 | call to operator new[] | memory allocation error check is incorrect or missing |
5-
| test.cpp:58:8:58:19 | call to operator new[] | memory allocation error check is incorrect or missing |
6-
| test.cpp:63:8:63:19 | call to operator new[] | memory allocation error check is incorrect or missing |
7-
| test.cpp:92:5:92:31 | call to operator new[] | memory allocation error check is incorrect or missing |
8-
| test.cpp:93:15:93:41 | call to operator new[] | memory allocation error check is incorrect or missing |
9-
| test.cpp:96:10:96:36 | call to operator new[] | memory allocation error check is incorrect or missing |
10-
| test.cpp:151:9:151:24 | call to operator new | memory allocation error check is incorrect or missing |
11-
| test.cpp:157:9:157:28 | call to operator new | memory allocation error check is incorrect or missing |
12-
| test.cpp:182:15:182:35 | call to operator new | memory allocation error check is incorrect or missing |
13-
| test.cpp:187:15:187:35 | call to operator new | memory allocation error check is incorrect or missing |
14-
| test.cpp:192:15:192:35 | call to operator new | memory allocation error check is incorrect or missing |
15-
| test.cpp:199:15:199:35 | call to operator new | memory allocation error check is incorrect or missing |
16-
| test.cpp:204:15:204:35 | call to operator new | memory allocation error check is incorrect or missing |
1+
| test.cpp:21:9:21:15 | new | This allocation cannot return null. $@ is unnecessary. | test.cpp:21:9:21:15 | new | This check |
2+
| test.cpp:29:13:29:24 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:30:7:30:13 | ... == ... | This check |
3+
| test.cpp:33:13:33:24 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:34:8:34:9 | p2 | This check |
4+
| test.cpp:37:13:37:24 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:38:7:38:16 | ... == ... | This check |
5+
| test.cpp:41:13:41:24 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:42:7:42:19 | ... == ... | This check |
6+
| test.cpp:45:13:45:24 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:46:7:46:8 | p5 | This check |
7+
| test.cpp:49:8:49:19 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:50:7:50:13 | ... == ... | This check |
8+
| test.cpp:53:8:53:19 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:54:8:54:9 | p7 | This check |
9+
| test.cpp:58:8:58:19 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:59:7:59:16 | ... == ... | This check |
10+
| test.cpp:63:8:63:19 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:64:7:64:19 | ... != ... | This check |
11+
| test.cpp:69:9:69:20 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:70:7:70:14 | ... != ... | This check |
12+
| test.cpp:75:11:75:22 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:76:13:76:15 | p11 | This check |
13+
| test.cpp:151:9:151:24 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:152:15:152:18 | { ... } | This catch block |
14+
| test.cpp:199:15:199:35 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:201:16:201:19 | { ... } | This catch block |

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-570/semmle/tests/test.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void *operator new(std::size_t, const std::nothrow_t &) noexcept;
1818
void *operator new[](std::size_t, const std::nothrow_t &) noexcept;
1919

2020
void bad_new_in_condition() {
21-
if (!(new int)) { // BAD [NOT DETECTED]
21+
if (!(new int)) { // BAD
2222
return;
2323
}
2424
}
@@ -30,7 +30,7 @@ void bad_new_missing_exception_handling() {
3030
if (p1 == 0)
3131
return;
3232

33-
int *p2 = new int[100]; // BAD [NOT DETECTED]
33+
int *p2 = new int[100]; // BAD
3434
if (!p2)
3535
return;
3636

@@ -42,15 +42,15 @@ void bad_new_missing_exception_handling() {
4242
if (p4 == nullptr)
4343
return;
4444

45-
int *p5 = new int[100]; // BAD [NOT DETECTED]
45+
int *p5 = new int[100]; // BAD
4646
if (p5) {} else return;
4747

4848
int *p6;
4949
p6 = new int[100]; // BAD
5050
if (p6 == 0) return;
5151

5252
int *p7;
53-
p7 = new int[100]; // BAD [NOT DETECTED]
53+
p7 = new int[100]; // BAD
5454
if (!p7)
5555
return;
5656

@@ -66,13 +66,13 @@ void bad_new_missing_exception_handling() {
6666
return;
6767

6868
int *p10;
69-
p10 = new int[100]; // BAD [NOT DETECTED]
69+
p10 = new int[100]; // BAD
7070
if (p10 != 0) {
7171
}
7272

7373
int *p11;
7474
do {
75-
p11 = new int[100]; // BAD [NOT DETECTED]
75+
p11 = new int[100]; // BAD
7676
} while (!p11);
7777

7878
int* p12 = new int[100];
@@ -154,7 +154,7 @@ void bad_placement_new_with_exception_handling() {
154154

155155
void good_placement_new_with_exception_handling() {
156156
char buffer[1024];
157-
try { new (buffer) Foo(42); } // GOOD: Foo constructor might throw [FALSE POSITIVE]
157+
try { new (buffer) Foo(42); } // GOOD: Foo constructor might throw
158158
catch (...) { }
159159
}
160160

@@ -179,17 +179,17 @@ void calls_non_throwing(int* p) {
179179

180180
void good_new_with_throwing_call() {
181181
try {
182-
int* p1 = new(std::nothrow) int; // GOOD [FALSE POSITIVE]
182+
int* p1 = new(std::nothrow) int; // GOOD
183183
may_throw();
184184
} catch(...) { }
185185

186186
try {
187-
int* p2 = new(std::nothrow) int; // GOOD [FALSE POSITIVE]
187+
int* p2 = new(std::nothrow) int; // GOOD
188188
Foo f(10);
189189
} catch(...) { }
190190

191191
try {
192-
int* p3 = new(std::nothrow) int; // GOOD [FALSE POSITIVE]
192+
int* p3 = new(std::nothrow) int; // GOOD
193193
calls_throwing_code(p3);
194194
} catch(...) { }
195195
}
@@ -201,7 +201,7 @@ void bad_new_with_nonthrowing_call() {
201201
} catch(...) { }
202202

203203
try {
204-
int* p2 = new(std::nothrow) int; // GOOD: boolean conversion constructor might throw [FALSE POSITIVE]
204+
int* p2 = new(std::nothrow) int; // GOOD: boolean conversion constructor might throw
205205
Foo f(12);
206206
if(f) { }
207207
} catch(...) { }

0 commit comments

Comments
 (0)