Skip to content

Commit 033edc2

Browse files
committed
C++: Respond to review comments.
1 parent 4b03778 commit 033edc2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @description Accessing the stack-allocated memory of a function
44
* after it has returned can lead to memory corruption.
55
* @kind problem
6-
* @problem.severity warning
6+
* @problem.severity error
77
* @security-severity 9.3
88
* @precision high
99
* @id cpp/using-expired-stack-address

cpp/ql/test/query-tests/Likely Bugs/Memory Management/UsingExpiredStackAddress/UsingExpiredStackAddress.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
| test.cpp:15:16:15:16 | Load: p | Stack variable $@ escapes $@ and is used after it has expired. | test.cpp:9:7:9:7 | x | x | test.cpp:10:3:10:13 | Store: ... = ... | here |
2-
| test.cpp:58:16:58:16 | Load: p | Stack variable $@ escapes $@ and is used after it has expired. | test.cpp:51:36:51:36 | x | x | test.cpp:52:3:52:13 | Store: ... = ... | here |
2+
| test.cpp:58:16:58:16 | Load: p | Stack variable $@ escapes $@ and is used after it has expired. | test.cpp:51:36:51:36 | y | y | test.cpp:52:3:52:13 | Store: ... = ... | here |
33
| test.cpp:73:16:73:16 | Load: p | Stack variable $@ escapes $@ and is used after it has expired. | test.cpp:62:7:62:7 | x | x | test.cpp:68:3:68:13 | Store: ... = ... | here |
44
| test.cpp:98:15:98:15 | Load: p | Stack variable $@ escapes $@ and is used after it has expired. | test.cpp:92:8:92:8 | s | s | test.cpp:93:3:93:15 | Store: ... = ... | here |
55
| test.cpp:111:16:111:16 | Load: p | Stack variable $@ escapes $@ and is used after it has expired. | test.cpp:102:7:102:7 | x | x | test.cpp:106:3:106:14 | Store: ... = ... | here |

cpp/ql/test/query-tests/Likely Bugs/Memory Management/UsingExpiredStackAddress/test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ int store_argument_value() {
4848
return *s101.p; // GOOD
4949
}
5050

51-
void store_address_of_argument(int x) {
52-
s101.p = &x;
51+
void store_address_of_argument(int y) {
52+
s101.p = &y;
5353
}
5454

5555
int store_argument_address() {
@@ -59,8 +59,8 @@ int store_argument_address() {
5959
}
6060

6161
void address_escapes_through_pointer_arith() {
62-
int x = 0;
63-
int* p0 = &x;
62+
int x[2];
63+
int* p0 = x;
6464
int* p1 = p0 + 1;
6565
int* p2 = p1 - 1;
6666
int* p3 = 1 + p2;

0 commit comments

Comments
 (0)