From abf1d456022220532ba3ac585a10da2101df62c8 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 1 Nov 2025 09:56:52 +0000 Subject: [PATCH] core: class: validate magic number in class header --- core/class.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/class.c b/core/class.c index 0967330..6d5942a 100644 --- a/core/class.c +++ b/core/class.c @@ -2,6 +2,7 @@ #include "type.h" +#include #include #include #include @@ -18,11 +19,23 @@ void *b_class_get(b_type id) const char *b_class_get_name(const struct _b_class *c) { + if (!c) { + return NULL; + } + + assert(c->c_magic == B_CLASS_MAGIC); + return c->c_type->r_info->t_name; } void *b_class_get_interface(const struct _b_class *c, const union b_type *id) { + if (!c) { + return NULL; + } + + assert(c->c_magic == B_CLASS_MAGIC); + const struct b_type_registration *type_reg = c->c_type; struct b_type_component *comp = b_type_get_component(&type_reg->r_components, id);