diff options
| author | Dmitry Antipov | 2014-07-09 14:36:35 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-07-09 14:36:35 +0400 |
| commit | 205ededbb23f8f1b182d9ae7c01d89b6e67e5736 (patch) | |
| tree | dc4fd300f19e002117f2d7be8a2772e117f3ec04 /src | |
| parent | 876d043fad0062a85ede5ab4f70c2e7f6d0e77ac (diff) | |
| download | emacs-205ededbb23f8f1b182d9ae7c01d89b6e67e5736.tar.gz emacs-205ededbb23f8f1b182d9ae7c01d89b6e67e5736.zip | |
* coding.c (ALLOC_CONVERSION_WORK_AREA): Prefer ptrdiff_t to int and
so avoid integer overflow if decoded gap size exceeds INT_MAX bytes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/coding.c | 11 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 10984d5ce25..fa79ac43bdf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -15,6 +15,9 @@ | |||
| 15 | * xfont.c (xfont_open): | 15 | * xfont.c (xfont_open): |
| 16 | * xftfont.c (xftfont_open): All users changed. | 16 | * xftfont.c (xftfont_open): All users changed. |
| 17 | 17 | ||
| 18 | * coding.c (ALLOC_CONVERSION_WORK_AREA): Prefer ptrdiff_t to int and | ||
| 19 | so avoid integer overflow if decoded gap size exceeds INT_MAX bytes. | ||
| 20 | |||
| 18 | 2014-07-09 Eli Zaretskii <eliz@gnu.org> | 21 | 2014-07-09 Eli Zaretskii <eliz@gnu.org> |
| 19 | 22 | ||
| 20 | * xdisp.c (move_it_to): Adjust calculation of line_start_x to what | 23 | * xdisp.c (move_it_to): Adjust calculation of line_start_x to what |
diff --git a/src/coding.c b/src/coding.c index d4c468cfbbf..5e7a676aecd 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -7273,15 +7273,12 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) | |||
| 7273 | 7273 | ||
| 7274 | #define ALLOC_CONVERSION_WORK_AREA(coding, size) \ | 7274 | #define ALLOC_CONVERSION_WORK_AREA(coding, size) \ |
| 7275 | do { \ | 7275 | do { \ |
| 7276 | int units = (size) + MAX_CHARBUF_EXTRA_SIZE; \ | 7276 | ptrdiff_t units = min ((size) + MAX_CHARBUF_EXTRA_SIZE, \ |
| 7277 | \ | 7277 | MAX_CHARBUF_SIZE); \ |
| 7278 | if (units > MAX_CHARBUF_SIZE) \ | 7278 | coding->charbuf = SAFE_ALLOCA (units * sizeof (int)); \ |
| 7279 | units = MAX_CHARBUF_SIZE; \ | 7279 | coding->charbuf_size = units; \ |
| 7280 | coding->charbuf = SAFE_ALLOCA ((units) * sizeof (int)); \ | ||
| 7281 | coding->charbuf_size = (units); \ | ||
| 7282 | } while (0) | 7280 | } while (0) |
| 7283 | 7281 | ||
| 7284 | |||
| 7285 | static void | 7282 | static void |
| 7286 | produce_annotation (struct coding_system *coding, ptrdiff_t pos) | 7283 | produce_annotation (struct coding_system *coding, ptrdiff_t pos) |
| 7287 | { | 7284 | { |