Package: python-vte
Version: 0.11.13-2

Attached is an example script that should set colors on a VTE Terminal widget to
be all white. It segfaults when run with the python-vte package.

I tracked the problem down to the python/vte.c file, in
_wrap_vte_terminal_set_colors(), line 472 or so:

    if (PySequence_Check(py_palette)) {
        palette_size = PySequence_Length(py_palette);
        palette = g_malloc(sizeof(GdkColor) * palette_size);
        for (i = 0; i < palette_size; i++) {
            item = PySequence_GetItem(py_palette, i); /* INCREFs */
            if (!pyg_boxed_check(item, GDK_TYPE_COLOR)) {
                g_free(palette);
                PyErr_SetString(PyExc_TypeError, "palette should be a list of 
GdkColors");
                return NULL;
            }
            /*           Good here              */
            palette[i] = *((GdkColor*)pyg_boxed_get(py_palette, GdkColor));
            /*      Never get here -- ^^^^^ segfaults!!       */
            printf("about to dec\n");
            Py_DECREF(item);
            printf("decremented successfully\n");
        }
    }

I think py_palette in this line should be changed to item. I haven't done any
strenuous testing, but this appears to make the program not seg fault.

Ethan
import gtk
import vte

w = gtk.Window()
v = vte.Terminal()
w.add(v)
v.show()
w.show()
black = gtk.gdk.Color(0, 0, 0)
white = gtk.gdk.Color(255, 255, 255)
palette = [gtk.gdk.Color(255,255,255) for x in range(8)]
v.set_colors(black, white, palette)
gtk.main()

Reply via email to