* coding.c (ALLOC_CONVERSION_WORK_AREA): Prefer ptrdiff_t to int and

so avoid integer overflow if decoded gap size exceeds INT_MAX bytes.
This commit is contained in:
Dmitry Antipov 2014-07-09 14:36:35 +04:00
parent 876d043fad
commit 205ededbb2
2 changed files with 7 additions and 7 deletions

View file

@ -15,6 +15,9 @@
* xfont.c (xfont_open): * xfont.c (xfont_open):
* xftfont.c (xftfont_open): All users changed. * xftfont.c (xftfont_open): All users changed.
* coding.c (ALLOC_CONVERSION_WORK_AREA): Prefer ptrdiff_t to int and
so avoid integer overflow if decoded gap size exceeds INT_MAX bytes.
2014-07-09 Eli Zaretskii <eliz@gnu.org> 2014-07-09 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (move_it_to): Adjust calculation of line_start_x to what * xdisp.c (move_it_to): Adjust calculation of line_start_x to what

View file

@ -7273,15 +7273,12 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
#define ALLOC_CONVERSION_WORK_AREA(coding, size) \ #define ALLOC_CONVERSION_WORK_AREA(coding, size) \
do { \ do { \
int units = (size) + MAX_CHARBUF_EXTRA_SIZE; \ ptrdiff_t units = min ((size) + MAX_CHARBUF_EXTRA_SIZE, \
\ MAX_CHARBUF_SIZE); \
if (units > MAX_CHARBUF_SIZE) \ coding->charbuf = SAFE_ALLOCA (units * sizeof (int)); \
units = MAX_CHARBUF_SIZE; \ coding->charbuf_size = units; \
coding->charbuf = SAFE_ALLOCA ((units) * sizeof (int)); \
coding->charbuf_size = (units); \
} while (0) } while (0)
static void static void
produce_annotation (struct coding_system *coding, ptrdiff_t pos) produce_annotation (struct coding_system *coding, ptrdiff_t pos)
{ {