1
0
Fork 0
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:
Dj 2023-04-01 09:26:02 +05:30 committed by GitHub
parent bafffa95a0
commit c162647020
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -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) {

View file

@ -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: {