Skip to content

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

@krichprollsch

Description

@krichprollsch

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:

  • use a C++ function to check if the js object prototype corresponds to the expected native type
  • add a second internal field with an integer identifying the native type

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions