changeset 110509:db816f28c44b

Avoid intervals crash by changing EMACS_UINTs to EMACS_INT. * intervals.c (traverse_intervals, rotate_right, rotate_left) (split_interval_right, find_interval, next_interval) (delete_node, delete_interval, interval_deletion_adjustment) (adjust_intervals_for_deletion, merge_interval_right) (merge_interval_left, graft_intervals_into_buffer) (copy_intervals): Convert EMACS_UINTs to EMACS_INT. * intervals.h (traverse_intervals): Update prototype.
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 23 Sep 2010 14:50:57 -0400
parents 2a5932eef2ba
children fa060a284a1b
files src/ChangeLog src/intervals.c src/intervals.h
diffstat 3 files changed, 35 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Sep 23 14:37:54 2010 -0400
+++ b/src/ChangeLog	Thu Sep 23 14:50:57 2010 -0400
@@ -1,3 +1,14 @@
+2010-09-23  Chong Yidong  <cyd@stupidchicken.com>
+
+	* intervals.c (traverse_intervals, rotate_right, rotate_left)
+	(split_interval_right, find_interval, next_interval)
+	(delete_node, delete_interval, interval_deletion_adjustment)
+	(adjust_intervals_for_deletion, merge_interval_right)
+	(merge_interval_left, graft_intervals_into_buffer)
+	(copy_intervals): Convert EMACS_UINTs to EMACS_INT.
+
+	* intervals.h (traverse_intervals): Update prototype.
+
 2010-09-23  Eli Zaretskii  <eliz@gnu.org>
 
 	* indent.c (compute_motion): Use EMACS_INT for arguments to
--- a/src/intervals.c	Thu Sep 23 14:37:54 2010 -0400
+++ b/src/intervals.c	Thu Sep 23 14:50:57 2010 -0400
@@ -222,7 +222,7 @@
    Pass FUNCTION two args: an interval, and ARG.  */
 
 void
-traverse_intervals (INTERVAL tree, EMACS_UINT position,
+traverse_intervals (INTERVAL tree, EMACS_INT position,
 		    void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg)
 {
   while (!NULL_INTERVAL_P (tree))
@@ -317,7 +317,7 @@
 {
   INTERVAL i;
   INTERVAL B = interval->left;
-  EMACS_UINT old_total = interval->total_length;
+  EMACS_INT old_total = interval->total_length;
 
   /* Deal with any Parent of A;  make it point to B.  */
   if (! ROOT_INTERVAL_P (interval))
@@ -364,7 +364,7 @@
 {
   INTERVAL i;
   INTERVAL B = interval->right;
-  EMACS_UINT old_total = interval->total_length;
+  EMACS_INT old_total = interval->total_length;
 
   /* Deal with any parent of A;  make it point to B.  */
   if (! ROOT_INTERVAL_P (interval))
@@ -506,8 +506,8 @@
 split_interval_right (INTERVAL interval, EMACS_INT offset)
 {
   INTERVAL new = make_interval ();
-  EMACS_UINT position = interval->position;
-  EMACS_UINT new_length = LENGTH (interval) - offset;
+  EMACS_INT position = interval->position;
+  EMACS_INT new_length = LENGTH (interval) - offset;
 
   new->position = position + offset;
   SET_INTERVAL_PARENT (new, interval);
@@ -618,7 +618,7 @@
 {
   /* The distance from the left edge of the subtree at TREE
                     to POSITION.  */
-  register EMACS_UINT relative_position;
+  register EMACS_INT relative_position;
 
   if (NULL_INTERVAL_P (tree))
     return NULL_INTERVAL;
@@ -671,7 +671,7 @@
 next_interval (register INTERVAL interval)
 {
   register INTERVAL i = interval;
-  register EMACS_UINT next_position;
+  register EMACS_INT next_position;
 
   if (NULL_INTERVAL_P (i))
     return NULL_INTERVAL;
@@ -1230,7 +1230,7 @@
 delete_node (register INTERVAL i)
 {
   register INTERVAL migrate, this;
-  register EMACS_UINT migrate_amt;
+  register EMACS_INT migrate_amt;
 
   if (NULL_INTERVAL_P (i->left))
     return i->right;
@@ -1263,7 +1263,7 @@
 delete_interval (register INTERVAL i)
 {
   register INTERVAL parent;
-  EMACS_UINT amt = LENGTH (i);
+  EMACS_INT amt = LENGTH (i);
 
   if (amt > 0)			/* Only used on zero-length intervals now.  */
     abort ();
@@ -1313,11 +1313,11 @@
    Do this by recursing down TREE to the interval in question, and
    deleting the appropriate amount of text.  */
 
-static EMACS_UINT
-interval_deletion_adjustment (register INTERVAL tree, register EMACS_UINT from,
-			      register EMACS_UINT amount)
+static EMACS_INT
+interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
+			      register EMACS_INT amount)
 {
-  register EMACS_UINT relative_position = from;
+  register EMACS_INT relative_position = from;
 
   if (NULL_INTERVAL_P (tree))
     return 0;
@@ -1325,9 +1325,9 @@
   /* Left branch */
   if (relative_position < LEFT_TOTAL_LENGTH (tree))
     {
-      EMACS_UINT subtract = interval_deletion_adjustment (tree->left,
-							  relative_position,
-							  amount);
+      EMACS_INT subtract = interval_deletion_adjustment (tree->left,
+							 relative_position,
+							 amount);
       tree->total_length -= subtract;
       CHECK_TOTAL_LENGTH (tree);
       return subtract;
@@ -1336,7 +1336,7 @@
   else if (relative_position >= (TOTAL_LENGTH (tree)
 				 - RIGHT_TOTAL_LENGTH (tree)))
     {
-      EMACS_UINT subtract;
+      EMACS_INT subtract;
 
       relative_position -= (tree->total_length
 			    - RIGHT_TOTAL_LENGTH (tree));
@@ -1351,7 +1351,7 @@
   else
     {
       /* How much can we delete from this interval?  */
-      EMACS_UINT my_amount = ((tree->total_length
+      EMACS_INT my_amount = ((tree->total_length
 			       - RIGHT_TOTAL_LENGTH (tree))
 			      - relative_position);
 
@@ -1381,7 +1381,7 @@
   register EMACS_INT left_to_delete = length;
   register INTERVAL tree = BUF_INTERVALS (buffer);
   Lisp_Object parent;
-  EMACS_UINT offset;
+  EMACS_INT offset;
 
   GET_INTERVAL_OBJECT (parent, tree);
   offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0);
@@ -1450,7 +1450,7 @@
 INTERVAL
 merge_interval_right (register INTERVAL i)
 {
-  register EMACS_UINT absorb = LENGTH (i);
+  register EMACS_INT absorb = LENGTH (i);
   register INTERVAL successor;
 
   /* Zero out this interval.  */
@@ -1506,7 +1506,7 @@
 INTERVAL
 merge_interval_left (register INTERVAL i)
 {
-  register EMACS_UINT absorb = LENGTH (i);
+  register EMACS_INT absorb = LENGTH (i);
   register INTERVAL predecessor;
 
   /* Zero out this interval.  */
@@ -1680,7 +1680,7 @@
 {
   register INTERVAL under, over, this, prev;
   register INTERVAL tree;
-  EMACS_UINT over_used;
+  EMACS_INT over_used;
 
   tree = BUF_INTERVALS (buffer);
 
@@ -2354,7 +2354,7 @@
 copy_intervals (INTERVAL tree, EMACS_INT start, EMACS_INT length)
 {
   register INTERVAL i, new, t;
-  register EMACS_UINT got, prevlen;
+  register EMACS_INT got, prevlen;
 
   if (NULL_INTERVAL_P (tree) || length <= 0)
     return NULL_INTERVAL;
--- a/src/intervals.h	Thu Sep 23 14:37:54 2010 -0400
+++ b/src/intervals.h	Thu Sep 23 14:50:57 2010 -0400
@@ -250,7 +250,7 @@
 extern INTERVAL create_root_interval (Lisp_Object);
 extern void copy_properties (INTERVAL, INTERVAL);
 extern int intervals_equal (INTERVAL, INTERVAL);
-extern void traverse_intervals (INTERVAL, EMACS_UINT,
+extern void traverse_intervals (INTERVAL, EMACS_INT,
                                 void (*) (INTERVAL, Lisp_Object),
                                 Lisp_Object);
 extern void traverse_intervals_noorder (INTERVAL,