[glib] gtype: fix a no-op assertion
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gtype: fix a no-op assertion
- Date: Tue, 27 Aug 2013 15:01:10 +0000 (UTC)
commit 34e1a537956e85d9d2db2127cd723a6c7456f793
Author: Dan Winship <danw gnome org>
Date: Tue Aug 27 09:40:18 2013 -0400
gtype: fix a no-op assertion
g_type_class_add_private() was doing
g_assert (node->data->instance.private_size <= 0xffff);
but that field is a guint16, so the check was a no-op. (Noticed by
clang, but not gcc for some reason.) Fix it to do the math in a gssize
variable and do the bounds checking there before updating the struct
field.
https://bugzilla.gnome.org/show_bug.cgi?id=706888
gobject/gtype.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gobject/gtype.c b/gobject/gtype.c
index 1445691..5051639 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -4503,8 +4503,9 @@ g_type_class_add_private (gpointer g_class,
G_WRITE_LOCK (&type_rw_lock);
- node->data->instance.private_size = ALIGN_STRUCT (node->data->instance.private_size + private_size);
- g_assert (node->data->instance.private_size <= 0xffff);
+ private_size = ALIGN_STRUCT (node->data->instance.private_size + private_size);
+ g_assert (private_size <= 0xffff);
+ node->data->instance.private_size = private_size;
G_WRITE_UNLOCK (&type_rw_lock);
}
@@ -4573,6 +4574,7 @@ g_type_class_adjust_private_offset (gpointer g_class,
{
GType class_gtype = ((GTypeClass *) g_class)->g_type;
TypeNode *node = lookup_type_node_I (class_gtype);
+ gssize private_size;
g_return_if_fail (private_size_or_offset != NULL);
@@ -4606,8 +4608,9 @@ g_type_class_adjust_private_offset (gpointer g_class,
G_WRITE_LOCK (&type_rw_lock);
- node->data->instance.private_size = ALIGN_STRUCT (node->data->instance.private_size +
*private_size_or_offset);
- g_assert (node->data->instance.private_size <= 0xffff);
+ private_size = ALIGN_STRUCT (node->data->instance.private_size + *private_size_or_offset);
+ g_assert (private_size <= 0xffff);
+ node->data->instance.private_size = private_size;
*private_size_or_offset = -(gint) node->data->instance.private_size;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]