[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r107074: Handle overflow when computi
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r107074: Handle overflow when computing char display width (Bug#9496). |
Date: |
Fri, 03 Feb 2012 11:24:22 -0800 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 107074
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Fri 2012-02-03 11:24:22 -0800
message:
Handle overflow when computing char display width (Bug#9496).
* character.c (char_width): Return EMACS_INT, not int.
(char_width, c_string_width): Check for overflow when
computing the width; this is possible now that individual
characters can have unbounded width. Problem introduced
by merge from Emacs 23 on 2012-01-19.
modified:
src/ChangeLog
src/character.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-02-02 12:47:09 +0000
+++ b/src/ChangeLog 2012-02-03 19:24:22 +0000
@@ -1,3 +1,12 @@
+2012-02-03 Paul Eggert <address@hidden>
+
+ Handle overflow when computing char display width (Bug#9496).
+ * character.c (char_width): Return EMACS_INT, not int.
+ (char_width, c_string_width): Check for overflow when
+ computing the width; this is possible now that individual
+ characters can have unbounded width. Problem introduced
+ by merge from Emacs 23 on 2012-01-19.
+
2012-02-02 Michael Albinus <address@hidden>
* dbusbind.c (Fdbus_register_method): Mention the return value
=== modified file 'src/character.c'
--- a/src/character.c 2012-01-19 07:21:25 +0000
+++ b/src/character.c 2012-02-03 19:24:22 +0000
@@ -311,10 +311,10 @@
/* Return width (columns) of C considering the buffer display table DP. */
-static int
+static EMACS_INT
char_width (int c, struct Lisp_Char_Table *dp)
{
- int width = CHAR_WIDTH (c);
+ EMACS_INT width = CHAR_WIDTH (c);
if (dp)
{
@@ -326,7 +326,12 @@
{
ch = AREF (disp, i);
if (CHARACTERP (ch))
- width += CHAR_WIDTH (XFASTINT (ch));
+ {
+ int w = CHAR_WIDTH (XFASTINT (ch));
+ if (INT_ADD_OVERFLOW (width, w))
+ string_overflow ();
+ width += w;
+ }
}
}
return width;
@@ -340,7 +345,8 @@
usage: (char-width CHAR) */)
(Lisp_Object ch)
{
- int c, width;
+ int c;
+ EMACS_INT width;
CHECK_CHARACTER (ch);
c = XINT (ch);
@@ -367,10 +373,14 @@
{
int bytes;
int c = STRING_CHAR_AND_LENGTH (str + i_byte, bytes);
- int thiswidth = char_width (c, dp);
+ EMACS_INT thiswidth = char_width (c, dp);
- if (precision > 0
- && (width + thiswidth > precision))
+ if (precision <= 0)
+ {
+ if (INT_ADD_OVERFLOW (width, thiswidth))
+ string_overflow ();
+ }
+ else if (precision - width < thiswidth)
{
*nchars = i;
*nbytes = i_byte;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r107074: Handle overflow when computing char display width (Bug#9496).,
Paul Eggert <=