Sema: fix UAF in zirClosureGet
Previously if a decl failed its capture scope would be deallocated and set to undefined which would then lead to invalid dereference in `zirClosureGet`. To avoid this set the capture scope to a special failed state and fail the current decl with dependency failure if the failed state is encountered in `zirClosureGet`. Closes #12433 Closes #12530 Closes #12593
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
pub inline fn instanceRequestAdapter() void {}
|
||||
|
||||
pub inline fn requestAdapter(
|
||||
comptime callbackArg: fn () callconv(.Inline) void,
|
||||
) void {
|
||||
_ = (struct {
|
||||
pub fn callback() callconv(.C) void {
|
||||
callbackArg();
|
||||
}
|
||||
}).callback;
|
||||
instanceRequestAdapter(undefined); // note wrong number of arguments here
|
||||
}
|
||||
|
||||
inline fn foo() void {}
|
||||
|
||||
pub export fn entry() void {
|
||||
requestAdapter(foo);
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :11:5: error: expected 0 argument(s), found 1
|
||||
// :1:12: note: function declared here
|
||||
// :17:19: note: called from here
|
||||
@@ -0,0 +1,24 @@
|
||||
fn Observable(comptime T: type) type {
|
||||
return struct {
|
||||
fn map(Src: T, Dst: anytype, function: fn (T) Dst) Dst {
|
||||
_ = Src;
|
||||
_ = function;
|
||||
return Observable(Dst);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn u32Tou64(x: u32) u64 {
|
||||
_ = x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pub export fn entry() void {
|
||||
Observable(u32).map(u32, u64, u32Tou64(0));
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :17:25: error: expected type 'u32', found 'type'
|
||||
Reference in New Issue
Block a user