From 7ccb823c07f5656136ed2b20abdb5a89e112d4cf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 30 Jan 2014 20:04:08 +0000 Subject: [PATCH 2/2] TpProtocol: fix some suspicious memory management It works fine as long as a preallocated GArray doesn't move its memory buffer for no reason, but it's good to be obviously correct. Spotted while working on the previous commit. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71093 --- telepathy-glib/protocol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c index ee9b7e2..3c7ed99 100644 --- a/telepathy-glib/protocol.c +++ b/telepathy-glib/protocol.c @@ -192,15 +192,15 @@ tp_protocol_params_from_param_specs (const GPtrArray *parameters, { GValue structure = { 0 }; GValue *tmp; - /* Points to the zeroed entry just after the end of the array - * - but we're about to extend the array to make it valid */ - TpConnectionManagerParam *param = &g_array_index (output, - TpConnectionManagerParam, output->len); + TpConnectionManagerParam *param; g_value_init (&structure, TP_STRUCT_TYPE_PARAM_SPEC); g_value_set_static_boxed (&structure, g_ptr_array_index (parameters, i)); g_array_set_size (output, output->len + 1); + /* point to the new last item */ + param = &g_array_index (output, TpConnectionManagerParam, + output->len - 1); if (!dbus_g_type_struct_get (&structure, 0, ¶m->name, -- 1.9.rc1