mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
fix(ext/ffi): crash when same reference struct is used in two fields (#18531)
fix #17482
This commit is contained in:
parent
bafffa95a0
commit
c162647020
2 changed files with 5 additions and 3 deletions
|
@ -313,8 +313,9 @@ function getTypeSizeAndAlignment(type, cache = new SafeMap()) {
|
|||
size += fieldSize;
|
||||
}
|
||||
size = MathCeil(size / alignment) * alignment;
|
||||
cache.set(type, size);
|
||||
return [size, alignment];
|
||||
const result = [size, alignment];
|
||||
cache.set(type, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -78,6 +78,7 @@ const Point = ["f64", "f64"];
|
|||
const Size = ["f64", "f64"];
|
||||
const Rect = ["f64", "f64", "f64", "f64"];
|
||||
const RectNested = [{ struct: Point }, { struct: Size }];
|
||||
const RectNestedCached = [{ struct: Size }, { struct: Size }];
|
||||
const Mixed = ["u8", "f32", { struct: Rect }, "usize", { struct: ["u32", "u32"] }];
|
||||
|
||||
const dylib = Deno.dlopen(libPath, {
|
||||
|
@ -264,7 +265,7 @@ const dylib = Deno.dlopen(libPath, {
|
|||
result: { struct: RectNested },
|
||||
},
|
||||
print_rect: {
|
||||
parameters: [{ struct: Rect }],
|
||||
parameters: [{ struct: RectNestedCached }],
|
||||
result: "void",
|
||||
},
|
||||
print_rect_async: {
|
||||
|
|
Loading…
Reference in a new issue