Skip to content

Return value of JS_NewClass not checked in js_std_init/js_os_init #404

@webmaster128

Description

@webmaster128

Hihi,

I am trying to debug crashes of quickjs in case of low memory settings. One of the problems I hit was

Assertion failed: (class_id < rt->class_count), function JS_SetClassProto, file quickjs.c, line 2208.

(which is here)

Turns out that this assertion is hit because the two JS_NewClass calls do not check the return value:

  1. JS_NewClass(JS_GetRuntime(ctx), js_std_file_class_id, &js_std_file_class);
  2. JS_NewClass(JS_GetRuntime(ctx), js_worker_class_id, &js_worker_class);

Do I understand this is a missing error check? Should I provide a PR to fix this? Is the error signature of JS_NewClass the same as JS_NewClass1?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions