GNOME Bugzilla – Bug 762819
Async method - overriding method returning a null-terminated array - leads to invalid C
Last modified: 2016-11-07 14:19:45 UTC
Created attachment 322577 [details] Testcase for the bug When a class defines an abstract method with "[CCode (array_length = false, array_null_terminated = true)]" attribute any method in a subclass overriding it produces invalid C code: /home/richard/src/valatest/test.vala.c:145:60: error: ‘FooGetStringAsyncData {aka struct _FooGetStringAsyncData}’ has no member named ‘result_length1’ _data_->result = (_vala_array_free (_data_->result, _data_->result_length1, (GDestroyNotify) g_free), NULL);
Commenting out valagasyncmodule.vala:127-128 solves the problem but introduces a memory leak obviously. Evil code: var v = new LocalVariable (m.return_type, ".result"); ccode.add_expression (destroy_local (v));
Created attachment 322595 [details] [review] Patch
Created attachment 322598 [details] [review] Patch Fix coding style
Created attachment 322602 [details] [review] Add test case to tests/
Created attachment 322606 [details] [review] add test case to tests/ fix test coding style
Looks like gdbus has similar code. I wonder if we have a better way to get a GLibValue consistent with the result var definition.
What about get_local_cvalue(m.result_var) ?
Created attachment 339253 [details] [review] Fix broken destruction of null-terminated arrays in async data structs
Attachment 339253 [details] pushed as 14cb50a - Fix broken destruction of null-terminated arrays in async data structs