guile-gtk-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sgtk_list2scm uninitialized res vs gc


From: Kevin Ryde
Subject: sgtk_list2scm uninitialized res vs gc
Date: Thu, 10 Mar 2005 10:19:20 +1100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)

In sgtk_list2scm in guile-gtk.c, it looks like "res" is uninitialized,
meaning I think that the last cdr in the result list being built
contains garbage, until the end of the function.

I got a segv when the scm_cons there had to do a gc and I suspect the
garbage is the cause.  Does that sound right?

This is a bit hard to reproduce, it happened in my chart program under
gtk-container-children converting a longish GList of widgets to an scm
list.

I'm looking at the change below, or at SCM_EOL always for the cdr of
the cons call, no need to fetch from *tail at all.

sgtk_slist2scm might have the same problem.

--- guile-gtk.c.~1.29.~ 2005-02-24 10:55:25.000000000 +1100
+++ guile-gtk.c 2005-03-10 10:09:32.345086136 +1100
@@ -1588,7 +1588,7 @@
 SCM
 sgtk_list2scm (GList *list, SCM (*toscm)(void*))
 {
-  SCM res, *tail = &res;
+  SCM res = SCM_EOL, *tail = &res;
   while (list)
     {
       *tail = scm_cons (toscm (&list->data), *tail);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]