diff options
| author | Dmitry Antipov <dmantipov@yandex.ru> | 2014-07-09 14:36:35 +0400 |
|---|---|---|
| committer | Dmitry Antipov <dmantipov@yandex.ru> | 2014-07-09 14:36:35 +0400 |
| commit | 205ededbb23f8f1b182d9ae7c01d89b6e67e5736 (patch) | |
| tree | dc4fd300f19e002117f2d7be8a2772e117f3ec04 /src/coding.c | |
| parent | 876d043fad0062a85ede5ab4f70c2e7f6d0e77ac (diff) | |
| download | emacs-205ededbb23f8f1b182d9ae7c01d89b6e67e5736.tar.gz | |
* 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/coding.c')
| -rw-r--r-- | src/coding.c | 11 |
1 files changed, 4 insertions, 7 deletions
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) #define ALLOC_CONVERSION_WORK_AREA(coding, size) \ do { \ - int units = (size) + MAX_CHARBUF_EXTRA_SIZE; \ - \ - if (units > MAX_CHARBUF_SIZE) \ - units = MAX_CHARBUF_SIZE; \ - coding->charbuf = SAFE_ALLOCA ((units) * sizeof (int)); \ - coding->charbuf_size = (units); \ + ptrdiff_t units = min ((size) + MAX_CHARBUF_EXTRA_SIZE, \ + MAX_CHARBUF_SIZE); \ + coding->charbuf = SAFE_ALLOCA (units * sizeof (int)); \ + coding->charbuf_size = units; \ } while (0) - static void produce_annotation (struct coding_system *coding, ptrdiff_t pos) { |
