Detected by valgrind :
==16102== Conditional jump or move depends on uninitialised value(s)
==16102== at 0x449A10: Drawing_Area::idle() (mandelbrot.cxx:143)
Helper function convert_crlf() from file fl_wayland_clipboard_dnd.cxx has been
repaired by commit a4b33f8 (13 jan 2023). But the same function was also in
file Fl_cocoa.mm. This commit moves the repaired code to class Fl_Screen_Driver
and has both fl_wayland_clipboard_dnd.cxx and Fl_cocoa.mm use it.
src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx:
- fix font_name_process() out of bounds memory access
- unify/align font_name_process() code (see also Xlib/xft)
- fix font name string allocation
src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
- unify/align font_name_process() code (see also Cairo_Graphics)
- fix font name string allocation
Todo: move common code to Fl_Graphics_Driver or another common file.
Error was reported by Address Sanitizer (ASAN) when picking a file.
Platform: Unix/Linux.
==1734703==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete []) on 0x607000108420
#0 0x7f3357d846ef in operator delete[](void*) ../../../../src/libsanitizer/asan/asan_new_delete.cc:168
#1 0x4e195f in Fl_Native_File_Chooser_Driver::strfree(char*) ../../src/Fl_Native_File_Chooser.cxx:262
...
0x607000108420 is located 0 bytes inside of 66-byte region [0x607000108420,0x607000108462)
allocated by thread T0 here:
#0 0x7f3357d0a3ed in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cc:445
#1 0x57951a in Fl_Kdialog_Native_File_Chooser_Driver::filter(char const*) ../../src/Fl_Native_File_Chooser_Kdialog.cxx:245
#2 0x4e14a0 in Fl_Native_File_Chooser::filter(char const*) ../../src/Fl_Native_File_Chooser.cxx:176
- replace strchr() with memchr() because buffer is not nul-terminated
- fix '*(p+1)' potentially accessing memory out of bounds
This fix also prevents
- multiple memmove() calls
- multiple searches from the beginning of the string
- add Fl_Scheme_Choice widget for quick scheme selection
- fix label alignment of selection box
- set selection_color()
- set selectbox()
- make the tree the resizable() of the window
This widget offers the selection of all known FLTK schemes as a simple
widget based on Fl_Choice.
Some test and demo programs use Fl_Scheme_Choice to enable the developer
or user to switch schemes quickly for comparison.
Todo:
- add features to add new schemes during runtime (partially done)
- update status when the scheme is changed by Fl::scheme("...")
Tall menus now work also as single popup window and show the correct selected item.
Groups of popups with a menutitle, an associated menuwindow, and possibly submenus
are constructed around the menuwindow, the menutitle being a child popup of the
menuwindow. This positions these popup groups better than before.
Many thanks to @wcout for providing this fix.
Xrender now draws images in the same way when tiling images
or not when FL_RGB_SCALING_BILINEAR is on.
This allows to remove static bool Fl_Tiled_Image::drawing_tiled_image()
which becomes unused.
The new method Fl::selection_to_clipboard(int) enables copying
selection data to the clipboard on X11 if it is set to 1.
This feature was requested by STR 3229 and the implementation was
inspired by an `xterm` feature named "Select to Clipboard" which can
be enabled by 'ctrl + middle mouse button + "Select to Clipboard"'
in an xterm window.