summaryrefslogtreecommitdiff
path: root/girepository/girnode.c
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2010-06-15 10:50:42 -0400
committerDavid Zeuthen <davidz@redhat.com>2010-06-24 11:53:18 -0400
commit751ffa016e410a031028282e63f98a94cc444b7b (patch)
tree4efa01403316b8e761dfd83e1d6f6eae70711c70 /girepository/girnode.c
parent3599c3727d87cb52728a47c31c50484769022745 (diff)
downloadgobject-introspection-751ffa016e410a031028282e63f98a94cc444b7b.tar.gz
Attribute bug-fixes
Rectify an assumption that nodes are ordered according to offset - since this assumption was not true, attributes ended up being not ordered either and the bsearch() when looking up attributes failed mysteriously. Instead of making such assumptions, simply sort the list of nodes we want to extract attributes from. The total attribute size computation was wrong as we didn't properly descend into subnodes. This resulted in memory access violations when writing the typelib (because not enough data was allocated). Instead of having a separate function for this, just include the attribute size in the existing function. See https://bugzilla.gnome.org/show_bug.cgi?id=571548 Signed-off-by: David Zeuthen <davidz@redhat.com>
Diffstat (limited to 'girepository/girnode.c')
-rw-r--r--girepository/girnode.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/girepository/girnode.c b/girepository/girnode.c
index 0f5223fa..fbdcdf96 100644
--- a/girepository/girnode.c
+++ b/girepository/girnode.c
@@ -573,7 +573,7 @@ add_attribute_size (gpointer key, gpointer value, gpointer data)
*size_p += ALIGN_VALUE (strlen (value_str) + 1, 4);
}
-/* returns the full size of the blob including variable-size parts */
+/* returns the full size of the blob including variable-size parts (including attributes) */
static guint32
g_ir_node_get_full_size_internal (GIrNode *parent,
GIrNode *node)
@@ -878,6 +878,8 @@ g_ir_node_get_full_size_internal (GIrNode *parent,
node->name ? "' " : "",
node, g_ir_node_type_to_string (node->type), size);
+ g_hash_table_foreach (node->attributes, add_attribute_size, &size);
+
return size;
}
@@ -887,14 +889,6 @@ g_ir_node_get_full_size (GIrNode *node)
return g_ir_node_get_full_size_internal (NULL, node);
}
-guint32
-g_ir_node_get_attribute_size (GIrNode *node)
-{
- guint32 size = 0;
- g_hash_table_foreach (node->attributes, add_attribute_size, &size);
- return size;
-}
-
int
g_ir_node_cmp (GIrNode *node,
GIrNode *other)
@@ -1438,7 +1432,7 @@ g_ir_node_build_typelib (GIrNode *node,
*/
g_assert (node->offset == 0);
node->offset = *offset;
- build->offset_ordered_nodes = g_list_prepend (build->offset_ordered_nodes, node);
+ build->nodes_with_attributes = g_list_prepend (build->nodes_with_attributes, node);
build->n_attributes += g_hash_table_size (node->attributes);