GNOME Bugzilla – Bug 443514
Incorrect freeing of SList of SLists
Last modified: 2008-10-25 05:52:18 UTC
Please describe the problem: A function that uses a list of lists (SLists) of strings is trying to free the first list with g_slist_foreach(list, g_free) instead of g_slist_foreach(list, g_slist_free). Steps to reproduce: 1. Write a method that creates a list of lists. 2. Compile the code 3. Actual results: Incorrect g_slist_free invocation. Expected results: g_slist_foreach(list, g_slist_free) Does this happen every time? yes Other information:
g_slist_foreach(list, g_slist_free) would also be incorrect as this wouldn't free the elements of the inner lists if that's necessary. This can only be fixed completely when bug 443522 has been fixed.
Lowering priority, I don't recommend you to use GList / GSList for anything more than simple lists, as they have quite some caveats. Multi-dimensional arrays might help in your case.
2008-05-11 Jürg Billeter <j@bitron.ch> * gobject/valaccodegenerator.vala: fix freeing nested GLists and GSLists, fixes bug 443514 Fixed in r1369.
test case added to vala-tests, still something wrong with memory. reopening
The issue in the test case is not the freeing as described in this bug but the copying of the list. l.copy() returns a SList<weak string> right now, however, Vala accepts appending even though it should only accept SList<string>. Replacing l.copy() by #l fixes the test case. The test case should still be fixed, of course, but this bug can be closed again.