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 562391 - Call dup_array with -1 length.
Call dup_array with -1 length.
Status: RESOLVED DUPLICATE of bug 514186
Product: vala
Classification: Core
Component: Arrays
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-26 22:23 UTC by Étienne Bersac
Modified: 2008-12-18 00:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Étienne Bersac 2008-11-26 22:23:37 UTC
Hi,

If i want to use NULL terminated array, the _vala_array_dup%d function is called with -1 args when passing array as argument.

Example code :

public struct TestStruct {
	[NoArrayLength]
	public string[] strings;

	[NoArrayLength]
	public TestStruct(string[] strings) {
		this.strings = strings;
	}
}

public int main(string[] args)
{
	string[] strings = { "test" };
	TestStruct ts = TestStruct(strings);
	debug("%s", ts.strings[0]);
	return 0;
}

Produced C snippet :

void test_struct_init (TestStruct *self, char** strings) {
	char** _tmp2;
	char** _tmp1;
	const char* _tmp0;
	memset (self, 0, sizeof (TestStruct));
	_tmp2 = NULL;
	_tmp1 = NULL;
	_tmp0 = NULL;
	(*self).strings = (_tmp2 = (_tmp1 = strings, (_tmp1 == NULL ? ((gpointer) (_tmp1)) : _vala_array_dup1 (_tmp1, -1))), ((*self).strings = (_vala_array_free ((*self).strings, -1, ((GDestroyNotify) (g_free))), NULL)), _tmp2);
}

The constructor use _vala_array_dup1 with -1 as length argument. Vala should use a _vala_array_dup_null_terminated variant of _vala_array_dup.

Étienne.
Comment 1 Jürg Billeter 2008-12-18 00:08:01 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.


*** This bug has been marked as a duplicate of 514186 ***