lightpanda-io / zig-js-runtime

Add a JS runtime in your Zig project
https://lightpanda.io
Apache License 2.0
16 stars 0 forks source link

getNativeObject: ensure the js object corresponds to the expected native type #189

Open krichprollsch opened 8 months ago

krichprollsch commented 8 months ago

getNativeObject doesn't check if the given js object corresponds to the expected native type.

Indeed, if we pass Car js object instead of a Brand, getNativeObject casts a native Car pointer as a Brand native object, leading to unknown behavior.

See https://github.com/lightpanda-io/jsruntime-lib/blob/main/src/engines/v8/generate.zig#L727

To ways are possible to do the check: