diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 1998-10-19 17:23:47 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 1998-10-19 17:23:47 +0000 |
| commit | 33ee986a7b69e05e1fe110c685747381bba481a9 (patch) | |
| tree | 3af602782ef5ba694903d539e7686eaef1214023 /src/fl_rect.cxx | |
| parent | f3fc32d284661926b36420d0fa615b655becf94a (diff) | |
Fixed some clipping stack bugs (no range checking).
git-svn-id: file:///fltk/svn/fltk/trunk@17 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_rect.cxx')
| -rw-r--r-- | src/fl_rect.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index ae31501a9..2a304f945 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -208,8 +208,10 @@ void fl_point(int x, int y) { //////////////////////////////////////////////////////////////// -static Region rstack[10]; -static int rstackptr; +#define STACK_SIZE 10 +#define STACK_MAX (STACK_SIZE - 1) +static Region rstack[STACK_SIZE]; +static int rstackptr=0; int fl_clip_state_number=0; // used by gl_begin.C to update GL clip #ifndef WIN32 @@ -267,20 +269,22 @@ void fl_clip(int x, int y, int w, int h) { r = CreateRectRgn(0,0,0,0); #endif } - rstack[++rstackptr] = r; + if (rstackptr < STACK_MAX) rstack[++rstackptr] = r; fl_restore_clip(); } // make there be no clip (used by fl_begin_offscreen() only!) void fl_push_no_clip() { - rstack[++rstackptr] = 0; + if (rstackptr < STACK_MAX) rstack[++rstackptr] = 0; fl_restore_clip(); } // pop back to previous clip: void fl_pop_clip() { - Region oldr = rstack[rstackptr--]; - if (oldr) XDestroyRegion(oldr); + if (rstackptr > 0) { + Region oldr = rstack[rstackptr--]; + if (oldr) XDestroyRegion(oldr); + } fl_restore_clip(); } |
