mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: Apply fixes from code review
This commit is contained in:
@@ -352,16 +352,12 @@ class PtrMutType extends PtrType {
|
||||
PtrMutType() { this.getStruct() instanceof Builtins::PtrMutType }
|
||||
|
||||
override string toString() { result = "*mut" }
|
||||
|
||||
override Location getLocation() { result instanceof EmptyLocation }
|
||||
}
|
||||
|
||||
class PtrConstType extends PtrType {
|
||||
PtrConstType() { this.getStruct() instanceof Builtins::PtrConstType }
|
||||
|
||||
override string toString() { result = "*const" }
|
||||
|
||||
override Location getLocation() { result instanceof EmptyLocation }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,11 +28,11 @@ fn raw_mut_borrow() {
|
||||
|
||||
fn raw_mut_write(cond: bool) {
|
||||
let a = 10i32;
|
||||
// The type of `x` must be inferred from the write below.
|
||||
// The type of `ptr_written` must be inferred from the write below.
|
||||
let ptr_written = null_mut(); // $ target=null_mut type=ptr_written:TPtrMut.i32
|
||||
if cond {
|
||||
unsafe {
|
||||
// NOTE: This write is undefined behavior because `x` is a null pointer.
|
||||
// NOTE: This write is undefined behavior because `ptr_written` is a null pointer.
|
||||
*ptr_written = a;
|
||||
let _y = *ptr_written; // $ type=_y:i32
|
||||
}
|
||||
@@ -40,11 +40,11 @@ fn raw_mut_write(cond: bool) {
|
||||
}
|
||||
|
||||
fn raw_type_from_deref(cond: bool) {
|
||||
// The type of `x` must be inferred from the read below.
|
||||
// The type of `ptr_read` must be inferred from the read below.
|
||||
let ptr_read = null_mut(); // $ target=null_mut type=ptr_read:TPtrMut.i64
|
||||
if cond {
|
||||
unsafe {
|
||||
// NOTE: This read is undefined behavior because `x` is a null pointer.
|
||||
// NOTE: This read is undefined behavior because `ptr_read` is a null pointer.
|
||||
let _y: i64 = *ptr_read;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user