diff options
| author | Martin Rudalics | 2019-03-04 10:28:56 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2019-03-04 10:28:56 +0100 |
| commit | ad25316bde7fece9745557f846170718837ee6da (patch) | |
| tree | 6c3751932be93d549de3777fc2dcc08356011ff6 /src | |
| parent | a810a75aa2d0cd5f43ec4b733fdcafabbfe8c5c3 (diff) | |
| download | emacs-ad25316bde7fece9745557f846170718837ee6da.tar.gz emacs-ad25316bde7fece9745557f846170718837ee6da.zip | |
Prevent introducing invalid scroll bar width/height values (Bug#34569)
* src/frame.c (store_frame_param): Don't store invalid values
for scroll_bar_width/height.
(x_report_frame_params): Don't report invalid values for
scroll_bar_width/height.
(x_set_scroll_bar_width, x_set_scroll_bar_height): Don't set
invalid values for scroll_bar_width/height.
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/frame.c b/src/frame.c index c7108d6a902..165ed4a4e52 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -2973,6 +2973,13 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) | |||
| 2973 | fset_buried_buffer_list (f, Fnreverse (list)); | 2973 | fset_buried_buffer_list (f, Fnreverse (list)); |
| 2974 | return; | 2974 | return; |
| 2975 | } | 2975 | } |
| 2976 | else if ((EQ (prop, Qscroll_bar_width) || EQ (prop, Qscroll_bar_height)) | ||
| 2977 | && !NILP (val) && !RANGED_FIXNUMP (1, val, INT_MAX)) | ||
| 2978 | { | ||
| 2979 | Lisp_Object old_val = Fcdr (Fassq (prop, f->param_alist)); | ||
| 2980 | |||
| 2981 | val = old_val; | ||
| 2982 | } | ||
| 2976 | 2983 | ||
| 2977 | /* The tty color needed to be set before the frame's parameter | 2984 | /* The tty color needed to be set before the frame's parameter |
| 2978 | alist was updated with the new value. This is not true any more, | 2985 | alist was updated with the new value. This is not true any more, |
| @@ -4117,18 +4124,14 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) | |||
| 4117 | store_in_alist (alistptr, Qright_fringe, | 4124 | store_in_alist (alistptr, Qright_fringe, |
| 4118 | make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f))); | 4125 | make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f))); |
| 4119 | store_in_alist (alistptr, Qscroll_bar_width, | 4126 | store_in_alist (alistptr, Qscroll_bar_width, |
| 4120 | (! FRAME_HAS_VERTICAL_SCROLL_BARS (f) | 4127 | (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 |
| 4121 | ? make_fixnum (0) | ||
| 4122 | : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 | ||
| 4123 | ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) | 4128 | ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) |
| 4124 | /* nil means "use default width" | 4129 | /* nil means "use default width" |
| 4125 | for non-toolkit scroll bar. | 4130 | for non-toolkit scroll bar. |
| 4126 | ruler-mode.el depends on this. */ | 4131 | ruler-mode.el depends on this. */ |
| 4127 | : Qnil)); | 4132 | : Qnil)); |
| 4128 | store_in_alist (alistptr, Qscroll_bar_height, | 4133 | store_in_alist (alistptr, Qscroll_bar_height, |
| 4129 | (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) | 4134 | (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0 |
| 4130 | ? make_fixnum (0) | ||
| 4131 | : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0 | ||
| 4132 | ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) | 4135 | ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) |
| 4133 | /* nil means "use default height" | 4136 | /* nil means "use default height" |
| 4134 | for non-toolkit scroll bar. */ | 4137 | for non-toolkit scroll bar. */ |
| @@ -4598,20 +4601,20 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 4598 | { | 4601 | { |
| 4599 | int unit = FRAME_COLUMN_WIDTH (f); | 4602 | int unit = FRAME_COLUMN_WIDTH (f); |
| 4600 | 4603 | ||
| 4601 | if (NILP (arg)) | 4604 | if (RANGED_FIXNUMP (1, arg, INT_MAX) |
| 4605 | && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) | ||
| 4602 | { | 4606 | { |
| 4603 | x_set_scroll_bar_default_width (f); | 4607 | FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg); |
| 4604 | 4608 | FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit; | |
| 4605 | if (FRAME_X_WINDOW (f)) | 4609 | if (FRAME_X_WINDOW (f)) |
| 4606 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); | 4610 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); |
| 4607 | 4611 | ||
| 4608 | SET_FRAME_GARBAGED (f); | 4612 | SET_FRAME_GARBAGED (f); |
| 4609 | } | 4613 | } |
| 4610 | else if (RANGED_FIXNUMP (1, arg, INT_MAX) | 4614 | else |
| 4611 | && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) | ||
| 4612 | { | 4615 | { |
| 4613 | FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg); | 4616 | x_set_scroll_bar_default_width (f); |
| 4614 | FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit; | 4617 | |
| 4615 | if (FRAME_X_WINDOW (f)) | 4618 | if (FRAME_X_WINDOW (f)) |
| 4616 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); | 4619 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); |
| 4617 | 4620 | ||
| @@ -4628,20 +4631,20 @@ x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 4628 | #if USE_HORIZONTAL_SCROLL_BARS | 4631 | #if USE_HORIZONTAL_SCROLL_BARS |
| 4629 | int unit = FRAME_LINE_HEIGHT (f); | 4632 | int unit = FRAME_LINE_HEIGHT (f); |
| 4630 | 4633 | ||
| 4631 | if (NILP (arg)) | 4634 | if (RANGED_FIXNUMP (1, arg, INT_MAX) |
| 4635 | && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) | ||
| 4632 | { | 4636 | { |
| 4633 | x_set_scroll_bar_default_height (f); | 4637 | FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg); |
| 4634 | 4638 | FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit; | |
| 4635 | if (FRAME_X_WINDOW (f)) | 4639 | if (FRAME_X_WINDOW (f)) |
| 4636 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); | 4640 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); |
| 4637 | 4641 | ||
| 4638 | SET_FRAME_GARBAGED (f); | 4642 | SET_FRAME_GARBAGED (f); |
| 4639 | } | 4643 | } |
| 4640 | else if (RANGED_FIXNUMP (1, arg, INT_MAX) | 4644 | else |
| 4641 | && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) | ||
| 4642 | { | 4645 | { |
| 4643 | FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg); | 4646 | x_set_scroll_bar_default_height (f); |
| 4644 | FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit; | 4647 | |
| 4645 | if (FRAME_X_WINDOW (f)) | 4648 | if (FRAME_X_WINDOW (f)) |
| 4646 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); | 4649 | adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); |
| 4647 | 4650 | ||