about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2024-01-02 16:09:55 +0100
committerbptato <nincsnevem662@gmail.com>2024-01-11 18:42:08 +0100
commitf8c9d3dcbb3199b5b165778755e5401e92ab8481 (patch)
tree279d32135a9a4ced698eb97700aa166a1de56291 /lib
parentb3d63266e43d628e5135ce751820ea0d62596c04 (diff)
downloadchawan-f8c9d3dcbb3199b5b165778755e5401e92ab8481.tar.gz
fixed crash in JS_DumpMemoryUsage (github issue #65)
Diffstat (limited to 'lib')
-rw-r--r--lib/quickjs/quickjs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 0c90815e..172d13e1 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -6380,10 +6380,10 @@ void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
             if (obj_classes[0])
                 fprintf(fp, "  %5d  %2.0d %s\n", obj_classes[0], 0, "none");
             for (class_id = 1; class_id < JS_CLASS_INIT_COUNT; class_id++) {
-                if (obj_classes[class_id]) {
+                if (obj_classes[class_id] && class_id < rt->class_count) {
                     char buf[ATOM_GET_STR_BUF_SIZE];
                     fprintf(fp, "  %5d  %2.0d %s\n", obj_classes[class_id], class_id,
-                            JS_AtomGetStrRT(rt, buf, sizeof(buf), js_std_class_def[class_id - 1].class_name));
+                            JS_AtomGetStrRT(rt, buf, sizeof(buf), rt->class_array[class_id].class_name));
                 }
             }
             if (obj_classes[JS_CLASS_INIT_COUNT])