diff mbox series

[01/26] object: add extra sanity checks

Message ID 20200110153039.1379601-2-marcandre.lureau@redhat.com
State New
Headers show
Series Various qom & qdev enhancements | expand

Commit Message

Marc-André Lureau Jan. 10, 2020, 3:30 p.m. UTC
Type system checked that children class_size >= parent class_size, but
not instances. Fix that.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qom/object.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Philippe Mathieu-Daudé Jan. 10, 2020, 7:18 p.m. UTC | #1
On 1/10/20 4:30 PM, Marc-André Lureau wrote:
> Type system checked that children class_size >= parent class_size, but
> not instances. Fix that.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   qom/object.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 0d971ca897..8453e4ac91 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -303,6 +303,7 @@ static void type_initialize(TypeImpl *ti)
>           int i;
>   
>           g_assert(parent->class_size <= ti->class_size);
> +        g_assert(parent->instance_size <= ti->instance_size);
>           memcpy(ti->class, parent->class, parent->class_size);
>           ti->class->interfaces = NULL;
>           ti->class->properties = g_hash_table_new_full(
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/qom/object.c b/qom/object.c
index 0d971ca897..8453e4ac91 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -303,6 +303,7 @@  static void type_initialize(TypeImpl *ti)
         int i;
 
         g_assert(parent->class_size <= ti->class_size);
+        g_assert(parent->instance_size <= ti->instance_size);
         memcpy(ti->class, parent->class, parent->class_size);
         ti->class->interfaces = NULL;
         ti->class->properties = g_hash_table_new_full(