Skip to content

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

@krichprollsch

Description

@krichprollsch
Member

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

Activity

changed the title [-]getNativeObject: ensure the js value corresponds to the expected type[/-] [+]getNativeObject: ensure the js objest corresponds to the expected native type[/+] on Jan 19, 2024
changed the title [-]getNativeObject: ensure the js objest corresponds to the expected native type[/-] [+]getNativeObject: ensure the js object corresponds to the expected native type[/+] on Jan 26, 2024
added this to the Invite Beta milestone on Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @krichprollsch@francisbouvier

        Issue actions

          getNativeObject: ensure the js object corresponds to the expected native type · Issue #189 · lightpanda-io/zig-js-runtime