mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
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>
This commit is contained in:
14
girnode.c
14
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);
|
||||
|
||||
|
Reference in New Issue
Block a user