changeset 13655:5dd2d988f3c3

(decode_mode_spec): For p and P, avoid overflow with large buffer sizes.
author Richard M. Stallman <rms@gnu.org>
date Mon, 27 Nov 1995 03:03:33 +0000
parents 645e14e39a2b
children b5b44ae33653
files src/xdisp.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Sun Nov 26 20:50:52 1995 +0000
+++ b/src/xdisp.c	Mon Nov 27 03:03:33 1995 +0000
@@ -3790,7 +3790,11 @@
 	  return "Top";
 	else
 	  {
-	    total = ((pos - BUF_BEGV (b)) * 100 + total - 1) / total;
+	    if (total > 1000000)
+	      /* Do it differently for a large value, to avoid overflow.  */
+	      total = ((pos - BUF_BEGV (b)) + (total / 100) - 1) / (total / 100);
+	    else
+	      total = ((pos - BUF_BEGV (b)) * 100 + total - 1) / total;
 	    /* We can't normally display a 3-digit number,
 	       so get us a 2-digit number that is close.  */
 	    if (total == 100)
@@ -3816,7 +3820,11 @@
 	  }
 	else
 	  {
-	    total = ((botpos - BUF_BEGV (b)) * 100 + total - 1) / total;
+	    if (total > 1000000)
+	      /* Do it differently for a large value, to avoid overflow.  */
+	      total = ((botpos - BUF_BEGV (b)) + (total / 100) - 1) / (total / 100);
+	    else
+	      total = ((botpos - BUF_BEGV (b)) * 100 + total - 1) / total;
 	    /* We can't normally display a 3-digit number,
 	       so get us a 2-digit number that is close.  */
 	    if (total == 100)