[Pkg-telepathy-commits] [telepathy-glib] 73/111: TpProtocol: fix some suspicious memory management

Simon McVittie smcv at debian.org
Wed Mar 19 18:07:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-glib.

commit 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, &param->name,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib.git



More information about the Pkg-telepathy-commits mailing list