diff options
| author | Robert Pluim | 2020-02-26 19:18:54 +0100 |
|---|---|---|
| committer | Robert Pluim | 2020-02-26 19:18:54 +0100 |
| commit | 999d75c0c1ce3dd19dfe376c0063951f9ba45900 (patch) | |
| tree | 0185f276ffdca4b8d097210cb15adf83a8eae179 /src | |
| parent | 29e415d6b04775b4b731cd70f11f353c3f64053e (diff) | |
| download | emacs-999d75c0c1ce3dd19dfe376c0063951f9ba45900.tar.gz emacs-999d75c0c1ce3dd19dfe376c0063951f9ba45900.zip | |
Range-check width passed to define-fringe-bitmap
This prevents a crash when attempting to create a zero-width bitmap.
* src/fringe.c (Fdefine_fringe_bitmap): Check value of width,
signal an error if outside documented range (Bug#39662).
Diffstat (limited to 'src')
| -rw-r--r-- | src/fringe.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/fringe.c b/src/fringe.c index 97aad843c2e..2a46e3c34f2 100644 --- a/src/fringe.c +++ b/src/fringe.c | |||
| @@ -1500,7 +1500,8 @@ DEFUN ("define-fringe-bitmap", Fdefine_fringe_bitmap, Sdefine_fringe_bitmap, | |||
| 1500 | BITMAP is a symbol identifying the new fringe bitmap. | 1500 | BITMAP is a symbol identifying the new fringe bitmap. |
| 1501 | BITS is either a string or a vector of integers. | 1501 | BITS is either a string or a vector of integers. |
| 1502 | HEIGHT is height of bitmap. If HEIGHT is nil, use length of BITS. | 1502 | HEIGHT is height of bitmap. If HEIGHT is nil, use length of BITS. |
| 1503 | WIDTH must be an integer between 1 and 16, or nil which defaults to 8. | 1503 | WIDTH must be an integer from 1 to 16, or nil which defaults to 8. An |
| 1504 | error is signaled if WIDTH is outside this range. | ||
| 1504 | Optional fifth arg ALIGN may be one of `top', `center', or `bottom', | 1505 | Optional fifth arg ALIGN may be one of `top', `center', or `bottom', |
| 1505 | indicating the positioning of the bitmap relative to the rows where it | 1506 | indicating the positioning of the bitmap relative to the rows where it |
| 1506 | is used; the default is to center the bitmap. Fifth arg may also be a | 1507 | is used; the default is to center the bitmap. Fifth arg may also be a |
| @@ -1535,7 +1536,9 @@ If BITMAP already exists, the existing definition is replaced. */) | |||
| 1535 | else | 1536 | else |
| 1536 | { | 1537 | { |
| 1537 | CHECK_FIXNUM (width); | 1538 | CHECK_FIXNUM (width); |
| 1538 | fb.width = max (0, min (XFIXNUM (width), 255)); | 1539 | fb.width = max (1, min (XFIXNUM (width), 16)); |
| 1540 | if (fb.width != XFIXNUM (width)) | ||
| 1541 | args_out_of_range (width, build_string ("Width must be from 1 to 16")); | ||
| 1539 | } | 1542 | } |
| 1540 | 1543 | ||
| 1541 | fb.period = 0; | 1544 | fb.period = 0; |