diff --git a/src/ChangeLog b/src/ChangeLog index b5e617b1f20..3bd4fc1f4c0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-04-09 Paul Eggert + * xdisp.c (vmessage): Use a better test for character truncation. + * charset.c (load_charset_map): <, not <=, for optimization, and to avoid potential problems with integer overflow. * chartab.c (sub_char_table_set_range, char_table_set_range): Likewise. diff --git a/src/xdisp.c b/src/xdisp.c index b1209b998e2..f37254419eb 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -8410,13 +8410,14 @@ vmessage (const char *m, va_list ap) { char *buf = FRAME_MESSAGE_BUF (f); size_t bufsize = FRAME_MESSAGE_BUF_SIZE (f); - int len = vsnprintf (buf, bufsize, m, ap); - if (len < 0) - len = 0; + int len; + + memset (buf, 0, bufsize); + len = vsnprintf (buf, bufsize, m, ap); /* Do any truncation at a character boundary. */ - if (0 < bufsize && bufsize <= len) - for (len = bufsize - 1; + if (! (0 <= len && len < bufsize)) + for (len = strnlen (buf, bufsize); len && ! CHAR_HEAD_P (buf[len - 1]); len--) continue; @@ -19495,7 +19496,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, EMACS_INT limit = BUF_BEGV (b); EMACS_INT limit_byte = BUF_BEGV_BYTE (b); EMACS_INT position; - EMACS_INT distance = + EMACS_INT distance = (height * 2 + 30) * line_number_display_limit_width; if (startpos - distance > limit)