From 9550d745cdcf4a819b4563338385d8626810ecb1 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Wed, 20 Jan 2016 22:24:08 +0000 Subject: Avoid clipping stack overruns in OpenGL graphics driver git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11018 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Gl_Window.cxx | 10 ++++++++++ src/fl_rect.cxx | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx index e74065ac6..82b38fd14 100644 --- a/src/Fl_Gl_Window.cxx +++ b/src/Fl_Gl_Window.cxx @@ -187,6 +187,8 @@ public: } void push_clip(int x, int y, int w, int h) { // TODO: implement OpenGL clipping + if (rstackptr < region_stack_max) rstack[++rstackptr] = 0L; + else Fl::warning("Fl_OpenGL_Graphics_Driver::push_clip: clip stack overflow!\n"); } int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) { // TODO: implement OpenGL clipping @@ -199,12 +201,20 @@ public: } void push_no_clip() { // TODO: implement OpenGL clipping + if (rstackptr < region_stack_max) rstack[++rstackptr] = 0; + else Fl::warning("Fl_OpenGL_Graphics_Driver::push_no_clip: clip stack overflow!\n"); + restore_clip(); } void pop_clip() { // TODO: implement OpenGL clipping + if (rstackptr > 0) { + rstackptr--; + } else Fl::warning("Fl_OpenGL_Graphics_Driver::pop_clip: clip stack underflow!\n"); + restore_clip(); } void restore_clip() { // TODO: implement OpenGL clipping + fl_clip_state_number++; } }; diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index 7979c1085..771cc6a8b 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -45,9 +45,9 @@ // This is defined in src/fl_line_style.cxx extern int fl_line_width_; + void Fl_Graphics_Driver::restore_clip() { fl_clip_state_number++; - Fl_Region r = rstack[rstackptr]; } void Fl_Graphics_Driver::clip_region(Fl_Region r) { -- cgit v1.2.3