telepathy-glib: TpProtocol: fix some suspicious memory management
Simon McVittie
smcv at kemper.freedesktop.org
Tue Feb 4 06:12:05 PST 2014
Module: telepathy-glib
Branch: master
Commit: 58557fc633c44c261d5e1a8c85438fa12bdf72e6
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=58557fc633c44c261d5e1a8c85438fa12bdf72e6
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Thu Jan 30 20:04:08 2014 +0000
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 at collabora.co.uk>
---
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,
More information about the telepathy-commits
mailing list