Merge lp://qastaging/~charlesk/libunity/lp-981309 into lp://qastaging/libunity

Proposed by Charles Kerr
Status: Merged
Approved by: Michal Hruby
Approved revision: 134
Merged at revision: 134
Proposed branch: lp://qastaging/~charlesk/libunity/lp-981309
Merge into: lp://qastaging/libunity
Diff against target: 13 lines (+2/-1)
1 file modified
src/unity-launcher.vala (+2/-1)
To merge this branch: bzr merge lp://qastaging/~charlesk/libunity/lp-981309
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+101998@code.qastaging.launchpad.net

Commit message

Plug a GHashTable leak in unity-launcher's serialize()

Description of the change

I'm still getting up to speed with Vala and am not sure whether or not this patch is The Right Fix.

Looking at the C code is useful: it looks like Vala's being confused by the implicit conversion of collect_launcher_entry_properties()'s return value from a HashTable to a Variant (ie, Variant foo = collect()).

If we add a HashTable local (ie, HashTable foo = collect(); Variant bar = foo;) then vala's C code correctly adds a call to g_hash_table_unref().

Here's the diff in valac's C code generated from that:

--- unity-launcher.c.bak 2012-04-13 20:04:07.813563352 -0500
+++ unity-launcher.c 2012-04-13 20:11:06.453573302 -0500
@@ -603,6 +603,7 @@
  UnityLauncherEntry * self;
  GVariant* result = NULL;
  GHashTable* _tmp0_ = NULL;
+ GHashTable* hash;
  GVariant* _tmp5_;
  GVariant* props;
  const gchar* _tmp6_;
@@ -619,7 +620,8 @@
  GVariant* _tmp15_;
  self = (UnityLauncherEntry*) base;
  _tmp0_ = unity_collect_launcher_entry_properties (self);
- _tmp5_ = _variant_new1 (_tmp0_);
+ hash = _tmp0_;
+ _tmp5_ = _variant_new1 (hash);
  props = _tmp5_;
  _tmp6_ = self->priv->_app_uri;
  _tmp7_ = g_variant_new_string (_tmp6_);
@@ -639,6 +641,7 @@
  result = _tmp15_;
  _g_variant_unref0 (_app_uri);
  _g_variant_unref0 (props);
+ _g_hash_table_unref0 (hash);
  return result;
 }

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Thanks Charles, yes this is the correct fix, we already saw a couple of instances of this. I checked with upstream Vala and they weren't aware of the issue, so it's now reported (bgo:674201).

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Revision history for this message
Charles Kerr (charlesk) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches