Skip to content

Commit 5bf799e

Browse files
geoffw0paldepind
andauthored
Apply suggestions from code review
Co-authored-by: Simon Friis Vindum <[email protected]>
1 parent df221ea commit 5bf799e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

rust/ql/lib/codeql/rust/security/AccessAfterLifetimeExtensions.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ module AccessAfterLifetime {
8181
}
8282

8383
/**
84-
* Holds if block `a` contains block `b`, in the sense that a variable in
85-
* `a` may be on the stack during execution of `b`. This is interprocedural,
84+
* Holds if block `a` contains block `b`, in the sense that a stack allocated variable in
85+
* `a` may still be on the stack during execution of `b`. This is interprocedural,
8686
* but is an overapproximation that doesn't accurately track call contexts
8787
* (for example if `f` and `g` both call `b`, then then depending on the
8888
* caller a variable in `f` or `g` may or may-not be on the stack during `b`).
8989
*/
90-
private predicate maybeOnStack(BlockExpr a, BlockExpr b) {
90+
private predicate blockStackEnclosing(BlockExpr a, BlockExpr b) {
9191
// `b` is a child of `a`
9292
a = b.getEnclosingBlock*()
9393
or

rust/ql/src/queries/security/CWE-825/AccessAfterLifetimeBad.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
fn get_pointer() -> *const i64 {
33
let val = 123;
44

5-
return &val;
5+
&val
66
} // lifetime of `val` ends here, the pointer becomes dangling
77

88
fn example() {

rust/ql/src/queries/security/CWE-825/AccessAfterLifetimeGood.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
fn get_box() -> Box<i64> {
33
let val = 123;
44

5-
return Box::new(val); // copies `val` onto the heap, where it remains for the lifetime of the `Box`.
5+
Box::new(val) // copies `val` onto the heap, where it remains for the lifetime of the `Box`.
66
}
77

88
fn example() {

0 commit comments

Comments
 (0)