diff --git a/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryFreed.expected b/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryFreed.expected index 26424477fcb..141b7091d19 100644 --- a/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryFreed.expected +++ b/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryFreed.expected @@ -26,7 +26,6 @@ | test.cpp:128:15:128:16 | v4 | | test.cpp:185:10:185:12 | cpy | | test.cpp:199:10:199:12 | cpy | -| test.cpp:205:7:205:11 | ... = ... | | test_free.cpp:11:10:11:10 | a | | test_free.cpp:14:10:14:10 | a | | test_free.cpp:16:10:16:10 | a | @@ -97,6 +96,7 @@ | test_free.cpp:255:10:255:10 | p | | test_free.cpp:260:9:260:9 | p | | test_free.cpp:263:12:263:12 | p | +| test_free.cpp:269:7:269:11 | ... = ... | | virtual.cpp:18:10:18:10 | a | | virtual.cpp:19:10:19:10 | c | | virtual.cpp:38:10:38:10 | b | diff --git a/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryMayNotBeFreed.expected b/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryMayNotBeFreed.expected index 01c81db9c3b..91bb79e6852 100644 --- a/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryMayNotBeFreed.expected +++ b/cpp/ql/test/query-tests/Critical/MemoryFreed/MemoryMayNotBeFreed.expected @@ -1,2 +1,2 @@ -| test.cpp:203:12:203:17 | call to malloc | This memory allocation may not be released at $@. | test.cpp:206:1:206:1 | return ... | this exit point | | test_free.cpp:36:22:36:35 | ... = ... | This memory allocation may not be released at $@. | test_free.cpp:38:1:38:1 | return ... | this exit point | +| test_free.cpp:267:12:267:17 | call to malloc | This memory allocation may not be released at $@. | test_free.cpp:270:1:270:1 | return ... | this exit point | diff --git a/cpp/ql/test/query-tests/Critical/MemoryFreed/test.cpp b/cpp/ql/test/query-tests/Critical/MemoryFreed/test.cpp index 4cee840a062..4f05f9d4954 100644 --- a/cpp/ql/test/query-tests/Critical/MemoryFreed/test.cpp +++ b/cpp/ql/test/query-tests/Critical/MemoryFreed/test.cpp @@ -198,9 +198,3 @@ void test_strndupa_dealloc() { char *cpy = strndupa(msg, 4); free(cpy); // BAD [NOT DETECTED] } - -void test_free_malloc() { - void *a = malloc(10); - void *b; - free(b = a); -} \ No newline at end of file diff --git a/cpp/ql/test/query-tests/Critical/MemoryFreed/test_free.cpp b/cpp/ql/test/query-tests/Critical/MemoryFreed/test_free.cpp index 82af587c8ee..b9ea0ec6fbf 100644 --- a/cpp/ql/test/query-tests/Critical/MemoryFreed/test_free.cpp +++ b/cpp/ql/test/query-tests/Critical/MemoryFreed/test_free.cpp @@ -261,4 +261,10 @@ void test_ref_delete(int *&p) { p = new int; use(p); // GOOD delete p; // GOOD +} + +void test_free_assign() { + void *a = malloc(10); + void *b; + free(b = a); // GOOD } \ No newline at end of file