After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620247 - sigsegv when reading a C array from a struct
sigsegv when reading a C array from a struct
Status: RESOLVED FIXED
Product: pygi
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal normal
: 0.6
Assigned To: pygi-maint
pygi-maint
: 620230 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-06-01 12:29 UTC by Tomeu Vizoso
Modified: 2010-06-02 17:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed fix (2.72 KB, patch)
2010-06-01 12:29 UTC, Tomeu Vizoso
committed Details | Review

Description Tomeu Vizoso 2010-06-01 12:29:33 UTC
Created attachment 162453 [details] [review]
proposed fix

Because _pygi_argument_to_object expects it to be a GArray.
Comment 1 Xavier Claessens 2010-06-01 12:44:45 UTC
This fix the issue I observed too.
Comment 2 Tomeu Vizoso 2010-06-02 17:43:08 UTC
*** Bug 620230 has been marked as a duplicate of this bug. ***
Comment 3 johnp 2010-06-02 17:50:05 UTC
Comment on attachment 162453 [details] [review]
proposed fix

>From ab25d3e86f7062c73bd6277c458683d702870964 Mon Sep 17 00:00:00 2001
>From: Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>
>Date: Tue, 1 Jun 2010 14:28:57 +0200
>Subject: [PATCH] Wrap C arrays in structs as GArrays before converting to Python
>
>---
> gi/pygi-info.c   |   11 +++++++++++
> tests/test_gi.py |   17 +++++++++++++++++
> 2 files changed, 28 insertions(+), 0 deletions(-)
>
>diff --git a/gi/pygi-info.c b/gi/pygi-info.c
>index c6b7bab..b7819ca 100644
>--- a/gi/pygi-info.c
>+++ b/gi/pygi-info.c
>@@ -1201,9 +1201,20 @@ _wrap_g_field_info_get_value (PyGIBaseInfo *self,
>         goto out;
>     }
> 
>+    if ( (g_type_info_get_tag (field_type_info) == GI_TYPE_TAG_ARRAY) &&
>+            (g_type_info_get_array_type (field_type_info) == GI_ARRAY_TYPE_C)) {
>+        value.v_pointer = _pygi_argument_to_array (&value, NULL,
>+                                                   field_type_info, FALSE);
>+    }
>+
> argument_to_object:
>     py_value = _pygi_argument_to_object (&value, field_type_info, GI_TRANSFER_NOTHING);
> 
>+    if ( (g_type_info_get_tag (field_type_info) == GI_TYPE_TAG_ARRAY) &&
>+            (g_type_info_get_array_type (field_type_info) == GI_ARRAY_TYPE_C)) {
>+        g_array_free (value.v_pointer, FALSE);
>+    }
>+
> out:
>     g_base_info_unref ( (GIBaseInfo *) field_type_info);
> 
>diff --git a/tests/test_gi.py b/tests/test_gi.py
>index eab9c8d..2541c2d 100644
>--- a/tests/test_gi.py
>+++ b/tests/test_gi.py
>@@ -734,6 +734,21 @@ class TestArray(unittest.TestCase):
>     def test_array_zero_terminated_inout(self):
>         self.assertEquals(('-1', '0', '1', '2'), GIMarshallingTests.array_zero_terminated_inout(('0', '1', '2')))
> 
>+    def test_gstrv_return(self):
>+        self.assertEquals(('0', '1', '2'), GIMarshallingTests.gstrv_return())
>+
>+    def test_gstrv_in(self):
>+        GIMarshallingTests.gstrv_in(Sequence(('0', '1', '2')))
>+
>+    def test_gstrv_out(self):
>+        self.assertEquals(('0', '1', '2'), GIMarshallingTests.gstrv_out())
>+
>+    def test_gstrv_out(self):
>+        self.assertEquals(('0', '1', '2'), GIMarshallingTests.gstrv_out())
>+
>+    def test_gstrv_inout(self):
>+        self.assertEquals(('-1', '0', '1', '2'), GIMarshallingTests.gstrv_inout(('0', '1', '2')))
>+
> 
> class TestGArray(unittest.TestCase):
> 
>@@ -1193,6 +1208,7 @@ class TestStructure(unittest.TestCase):
>         self.assertTrue(isinstance(struct, GIMarshallingTests.BoxedStruct))
> 
>         self.assertEquals(0, struct.long_)
>+        self.assertEquals(None, struct.g_strv)
> 
>         del struct
> 
>@@ -1216,6 +1232,7 @@ class TestStructure(unittest.TestCase):
> 
>         self.assertTrue(isinstance(struct, GIMarshallingTests.BoxedStruct))
>         self.assertEquals(42, struct.long_)
>+        self.assertEquals(('0', '1', '2'), struct.g_strv)
> 
>         del struct
> 
>-- 
>1.6.6.1
>