mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -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 += fieldSize;
|
||||||
}
|
}
|
||||||
size = MathCeil(size / alignment) * alignment;
|
size = MathCeil(size / alignment) * alignment;
|
||||||
cache.set(type, size);
|
const result = [size, alignment];
|
||||||
return [size, alignment];
|
cache.set(type, result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
|
@ -78,6 +78,7 @@ const Point = ["f64", "f64"];
|
||||||
const Size = ["f64", "f64"];
|
const Size = ["f64", "f64"];
|
||||||
const Rect = ["f64", "f64", "f64", "f64"];
|
const Rect = ["f64", "f64", "f64", "f64"];
|
||||||
const RectNested = [{ struct: Point }, { struct: Size }];
|
const RectNested = [{ struct: Point }, { struct: Size }];
|
||||||
|
const RectNestedCached = [{ struct: Size }, { struct: Size }];
|
||||||
const Mixed = ["u8", "f32", { struct: Rect }, "usize", { struct: ["u32", "u32"] }];
|
const Mixed = ["u8", "f32", { struct: Rect }, "usize", { struct: ["u32", "u32"] }];
|
||||||
|
|
||||||
const dylib = Deno.dlopen(libPath, {
|
const dylib = Deno.dlopen(libPath, {
|
||||||
|
@ -264,7 +265,7 @@ const dylib = Deno.dlopen(libPath, {
|
||||||
result: { struct: RectNested },
|
result: { struct: RectNested },
|
||||||
},
|
},
|
||||||
print_rect: {
|
print_rect: {
|
||||||
parameters: [{ struct: Rect }],
|
parameters: [{ struct: RectNestedCached }],
|
||||||
result: "void",
|
result: "void",
|
||||||
},
|
},
|
||||||
print_rect_async: {
|
print_rect_async: {
|
||||||
|
|
Loading…
Reference in a new issue