From: Richard M. Stallman Date: Mon, 27 Nov 1995 03:03:33 +0000 (+0000) Subject: (decode_mode_spec): For p and P, avoid overflow with large buffer sizes. X-Git-Tag: emacs-19.34~2205 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3c7d31b921c1f532f0c2ff6b97a1cb9c93617dbf;p=emacs.git (decode_mode_spec): For p and P, avoid overflow with large buffer sizes. --- diff --git a/src/xdisp.c b/src/xdisp.c index a1b5a2ea88f..86836714dcf 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3790,7 +3790,11 @@ decode_mode_spec (w, c, spec_width, maxwidth) 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 @@ decode_mode_spec (w, c, spec_width, maxwidth) } 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)