From 7c9a753007a78e1fde35ee37255fbc3532f4ed89 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 25 Oct 2025 00:00:37 +0100 Subject: [PATCH] core: object: add nullptr checks to data retrieval functions --- core/object.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/object.c b/core/object.c index 2d8016e..513242a 100644 --- a/core/object.c +++ b/core/object.c @@ -92,6 +92,10 @@ bool b_object_is_type(const struct _b_object *p, b_type type) void *b_object_get_private(const struct _b_object *object, b_type type) { + if (!object) { + return NULL; + } + if (b_type_id_compare(&object->obj_type->r_info->t_id, type) == 0) { return (char *)object + object->obj_main_priv_offset; } @@ -107,6 +111,10 @@ void *b_object_get_private(const struct _b_object *object, b_type type) void *b_object_get_protected(const struct _b_object *object, b_type type) { + if (!object) { + return NULL; + } + struct b_type_component *comp = b_type_get_component(&object->obj_type->r_components, type); if (!comp) { @@ -118,6 +126,10 @@ void *b_object_get_protected(const struct _b_object *object, b_type type) void *b_object_get_interface(const struct _b_object *object, b_type type) { + if (!object) { + return NULL; + } + return b_class_get_interface(object->obj_type->r_class, type); } @@ -125,6 +137,10 @@ enum b_status b_object_get_data( const struct _b_object *object, b_type type, void **priv, void **prot, void **iface) { + if (!object) { + return B_ERR_INVALID_ARGUMENT; + } + struct b_type_component *comp = b_type_get_component(&object->obj_type->r_components, type); if (!comp) {