Package: libstfl-dev
Version: 0.18-2
Severity: normal
Segmentation fault occurs if root widget was replaced.
Testcase and patch were attached.
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.25-rc5-mm1
Locale: LANG=ja_JP.eucJP, LC_CTYPE=ja_JP.eucJP (charmap=EUC-JP)
Shell: /bin/sh linked to /bin/bash
Versions of packages libstfl-dev depends on:
ii libncursesw5-dev 5.6+20080405-1 Developer's libraries for ncursesw
libstfl-dev recommends no packages.
-- no debconf information
#include <stfl.h>
#include <locale.h>
#include <stdio.h>
#include <langinfo.h>
int main(void)
{
struct stfl_form *form;
struct stfl_ipool *ipool;
const wchar_t *dump;
if (setlocale(LC_ALL, "") == NULL)
{
perror("setlocale");
return 1;
}
form = stfl_create(L"vbox[a]\n vbox[b]\n list\n listitem
text:Asafffffff\n");
ipool = stfl_ipool_create(nl_langinfo(CODESET));
puts(stfl_ipool_fromwc(ipool, stfl_dump(form, NULL, NULL, 0)));
dump = stfl_dump(form, L"a", NULL, 0);
puts(stfl_ipool_fromwc(ipool, dump));
stfl_modify(form, L"a", L"replace", dump);
puts(stfl_ipool_fromwc(ipool, stfl_dump(form, NULL, NULL, 0)));
stfl_ipool_flush(ipool);
stfl_ipool_destroy(ipool);
stfl_free(form);
return 0;
}
diff -uNrp stfl-0.18.orig/public.c stfl-0.18/public.c
--- stfl-0.18.orig/public.c 2007-11-11 21:28:52.000000000 +0900
+++ stfl-0.18/public.c 2008-04-15 00:11:49.000000000 +0900
@@ -302,7 +302,10 @@ void stfl_modify(struct stfl_form *f, co
mode = mode ? mode : L"";
if (!wcscmp(mode, L"replace")) {
- stfl_modify_after(w, n);
+ if (w == f->root)
+ f->root = n;
+ else
+ stfl_modify_after(w, n);
stfl_widget_free(w);
goto finish;
}