Skip to content

Commit 17ff342

Browse files
committed
C++: Resolve the overlap.
1 parent 7db2b2c commit 17ff342

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

cpp/ql/src/Critical/SizeCheck2.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ where
5858
not exists(int size | base.getSize() = size |
5959
size = 0 or
6060
(allocated / size) * size = allocated
61-
)
61+
) and
62+
not basesize > allocated // covered by SizeCheck.ql
6263
select alloc,
6364
"Allocated memory (" + allocated.toString() + " bytes) is not a multiple of the size of '" +
6465
base.getName() + "' (" + basesize.toString() + " bytes)."

cpp/ql/test/query-tests/Critical/SizeCheck/SizeCheck2.expected

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,3 @@
22
| test2.c:17:20:17:25 | call to malloc | Allocated memory (33 bytes) is not a multiple of the size of 'double' (8 bytes). |
33
| test2.c:32:23:32:28 | call to malloc | Allocated memory (28 bytes) is not a multiple of the size of 'long long' (8 bytes). |
44
| test2.c:33:20:33:25 | call to malloc | Allocated memory (20 bytes) is not a multiple of the size of 'double' (8 bytes). |
5-
| test.c:16:19:16:24 | call to malloc | Allocated memory (3 bytes) is not a multiple of the size of 'float' (4 bytes). |
6-
| test.c:17:20:17:25 | call to malloc | Allocated memory (5 bytes) is not a multiple of the size of 'double' (8 bytes). |
7-
| test.c:32:19:32:24 | call to malloc | Allocated memory (2 bytes) is not a multiple of the size of 'float' (4 bytes). |
8-
| test.c:33:20:33:25 | call to malloc | Allocated memory (4 bytes) is not a multiple of the size of 'double' (8 bytes). |
9-
| test.c:59:15:59:20 | call to malloc | Allocated memory (8 bytes) is not a multiple of the size of 'MyUnion' (128 bytes). |

0 commit comments

Comments
 (0)