core: object: validate magic number in object header
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <blue/core/class.h>
|
#include <blue/core/class.h>
|
||||||
#include <blue/core/macros.h>
|
#include <blue/core/macros.h>
|
||||||
#include <blue/core/object.h>
|
#include <blue/core/object.h>
|
||||||
@@ -98,6 +99,8 @@ void *b_object_get_private(const struct _b_object *object, b_type type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(object->obj_magic == B_OBJECT_MAGIC);
|
||||||
|
|
||||||
if (b_type_id_compare(&object->obj_type->r_info->t_id, type) == 0) {
|
if (b_type_id_compare(&object->obj_type->r_info->t_id, type) == 0) {
|
||||||
return (char *)object + object->obj_main_priv_offset;
|
return (char *)object + object->obj_main_priv_offset;
|
||||||
}
|
}
|
||||||
@@ -117,6 +120,8 @@ void *b_object_get_protected(const struct _b_object *object, b_type type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(object->obj_magic == B_OBJECT_MAGIC);
|
||||||
|
|
||||||
struct b_type_component *comp
|
struct b_type_component *comp
|
||||||
= b_type_get_component(&object->obj_type->r_components, type);
|
= b_type_get_component(&object->obj_type->r_components, type);
|
||||||
if (!comp) {
|
if (!comp) {
|
||||||
@@ -132,6 +137,8 @@ void *b_object_get_interface(const struct _b_object *object, b_type type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(object->obj_magic == B_OBJECT_MAGIC);
|
||||||
|
|
||||||
return b_class_get_interface(object->obj_type->r_class, type);
|
return b_class_get_interface(object->obj_type->r_class, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +150,8 @@ enum b_status b_object_get_data(
|
|||||||
return B_ERR_INVALID_ARGUMENT;
|
return B_ERR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(object->obj_magic == B_OBJECT_MAGIC);
|
||||||
|
|
||||||
struct b_type_component *comp
|
struct b_type_component *comp
|
||||||
= b_type_get_component(&object->obj_type->r_components, type);
|
= b_type_get_component(&object->obj_type->r_components, type);
|
||||||
if (!comp) {
|
if (!comp) {
|
||||||
|
|||||||
Reference in New Issue
Block a user