Sfoglia il codice sorgente

Move custom FLTK box types to valid range

FLTK only allows 256 different box types, but it doesn't actually check
this when registering new ones.

Move our custom types to a valid range, and add an assert for good
measure to make sure we don't overflow FLTK's internal structures.
pull/1659/head
Pierre Ossman 8 mesi fa
parent
commit
4cef5c996f
2 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 5
    0
      vncviewer/fltk/theme.cxx
  2. 1
    1
      vncviewer/fltk/theme.h

+ 5
- 0
vncviewer/fltk/theme.cxx Vedi File

@@ -25,6 +25,8 @@
#include <config.h>
#endif

#include <assert.h>

#ifdef WIN32
#include <windows.h>
#endif
@@ -271,6 +273,9 @@ void init_theme()
const int PX = 2;
const int PY = 2;

// FLTK lacks a bounds check
assert(THEME_ROUND_DOWN_BOX < 256);

Fl::set_boxtype(THEME_UP_FRAME, theme_up_frame, PX, PY, PX*2, PY*2);
Fl::set_boxtype(THEME_DOWN_FRAME, theme_down_frame, PX, PY, PX*2, PY*2);
Fl::set_boxtype(THEME_THIN_UP_FRAME, theme_up_frame, PX, PY, PX*2, PY*2);

+ 1
- 1
vncviewer/fltk/theme.h Vedi File

@@ -26,7 +26,7 @@

#include <FL/Enumerations.H>

#define _THEME_BOX_BASE (FL_FREE_BOXTYPE+1000)
#define _THEME_BOX_BASE (FL_FREE_BOXTYPE+20)

#define THEME_UP_FRAME (Fl_Boxtype)(_THEME_BOX_BASE+0)
#define THEME_DOWN_FRAME (Fl_Boxtype)(_THEME_BOX_BASE+1)

Loading…
Annulla
Salva