瀏覽代碼

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 月之前
父節點
當前提交
4cef5c996f
共有 2 個檔案被更改,包括 6 行新增1 行删除
  1. 5
    0
      vncviewer/fltk/theme.cxx
  2. 1
    1
      vncviewer/fltk/theme.h

+ 5
- 0
vncviewer/fltk/theme.cxx 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存