[gobject-introspection/gnome-3-4] Avoid _get_func() consuming reference from input info
- From: Pavel Holejsovsky <pholejs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/gnome-3-4] Avoid _get_func() consuming reference from input info
- Date: Wed, 11 Apr 2012 18:39:45 +0000 (UTC)
commit 2bcf6395a17c655d5164b1a9fb3c3bb5aedda376
Author: Pavel Holejsovsky <pavel holejsovsky gmail com>
Date: Sat Mar 31 19:12:48 2012 +0200
Avoid _get_func() consuming reference from input info
Fix of leak in 4c9424e18d71237f438a99bc5f2d45ae7de60b78 was a bit
overaggressive, stealing also one reference from input 'info'
argument.
Also fixes another bug in that commit - local 'func' shadowing the
return value, causing that function always returned NULL even when
some result was actually found.
https://bugzilla.gnome.org/show_bug.cgi?id=673282
girepository/giobjectinfo.c | 3 +--
tests/repository/gitypelibtest.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c
index 3b8f64b..7ba2a93 100644
--- a/girepository/giobjectinfo.c
+++ b/girepository/giobjectinfo.c
@@ -819,7 +819,7 @@ _get_func(GIObjectInfo *info,
GIObjectInfo *parent_info;
gpointer func = NULL;
- parent_info = info;
+ parent_info = g_base_info_ref (info);
while (parent_info != NULL)
{
parents = g_slist_prepend (parents, parent_info);
@@ -828,7 +828,6 @@ _get_func(GIObjectInfo *info,
for (l = parents; l; l = l->next)
{
- GIObjectInfoRefFunction func;
parent_info = l->data;
symbol = getter (parent_info);
if (symbol == NULL)
diff --git a/tests/repository/gitypelibtest.c b/tests/repository/gitypelibtest.c
index 15722a6..c53eab2 100644
--- a/tests/repository/gitypelibtest.c
+++ b/tests/repository/gitypelibtest.c
@@ -156,6 +156,18 @@ test_is_pointer_for_struct_arg (GIRepository *repo)
g_base_info_unref (variant_info);
}
+static void
+test_fundamental_get_ref_function_pointer (GIRepository *repo)
+{
+ GIObjectInfo *info;
+
+ g_assert (g_irepository_require (repo, "Regress", NULL, 0, NULL));
+ info = g_irepository_find_by_name (repo, "Regress",
+ "TestFundamentalObject");
+ g_object_info_get_ref_function_pointer (info);
+ g_base_info_unref (info);
+}
+
int
main(int argc, char **argv)
{
@@ -170,6 +182,7 @@ main(int argc, char **argv)
test_enum_and_flags_static_methods (repo);
test_size_of_gvalue (repo);
test_is_pointer_for_struct_arg (repo);
+ test_fundamental_get_ref_function_pointer (repo);
exit(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]