[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[XForms] Segfault after fl_finish and fix
From: |
Steven G. Messervey |
Subject: |
[XForms] Segfault after fl_finish and fix |
Date: |
Mon, 3 Oct 2016 21:12:18 -0400 |
Hello,
From my understanding, if you call fl_finish in a callback, fl_do_forms
should return.
Instead, tt segfaults.
Debian Wheezy 64-bit on x86_64.
Simple program to demonstrate the issue:
#include <forms.h>
void callback(FL_OBJECT *obj, long data) {
fl_finish();
}
int main(int argc, char **argv) {
FL_FORM *form;
FL_OBJECT *btn;
fl_initialize(&argc, argv, "TEST", 0, 0);
form = fl_bgn_form(FL_UP_BOX,320,120);
btn = fl_add_button(FL_NORMAL_BUTTON,40,70,80,30,"Click me");
fl_set_object_callback(btn,callback,0);
fl_end_form();
fl_show_form(form, FL_PLACE_MOUSE, FL_TRANSIENT, "FOO");
fl_do_forms();
return 0;
}
My proposed fix:
In lib/events.c - fli_object_qread():
replace all occurrences of fli_context = <some value>; with:
if (fli_context)
fli_context = <some_value>.
After applying the fix and recompiling, the above program works.
I discovered it while making XForms bindings to javascript (Duktape).
Thanks,
Steve M.
- [XForms] Segfault after fl_finish and fix,
Steven G. Messervey <=