[gobject-introspection/wip/fmuellner/fix-method-offset] structinfo: Fix offset in find_method()



commit 722d59c14cd0a82a0373fb305d0157f5281c076e
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Aug 14 23:09:52 2019 +0200

    structinfo: Fix offset in find_method()
    
    The current offset only considers the fields themselves, but not
    the optional embedded type that may follow each field.
    
    Use the existing helper function instead of computing the offset
    to fix the issue.

 girepository/gistructinfo.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
---
diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c
index 7db417fc..a1edfa9f 100644
--- a/girepository/gistructinfo.c
+++ b/girepository/gistructinfo.c
@@ -215,12 +215,9 @@ g_struct_info_find_method (GIStructInfo *info,
 {
   gint offset;
   GIRealInfo *rinfo = (GIRealInfo *)info;
-  Header *header = (Header *)rinfo->typelib->data;
   StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
 
-  offset = rinfo->offset + header->struct_blob_size
-    + blob->n_fields * header->field_blob_size;
-
+  offset = g_struct_get_field_offset (info, blob->n_fields);
   return _g_base_info_find_method ((GIBaseInfo*)info, offset, blob->n_methods, name);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]