summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-30 20:04:08 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-02-04 12:52:38 +0000
commit58557fc633c44c261d5e1a8c85438fa12bdf72e6 (patch)
tree21cb59589d2fab54e3b457863578a8d414cf00c0
parentbdba6fdf7804c050197db70d5840ae0f96cfe4be (diff)
downloadtelepathy-glib-58557fc633c44c261d5e1a8c85438fa12bdf72e6.tar.gz
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 Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r--telepathy-glib/protocol.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index ee9b7e282..3c7ed9916 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, &param->name,