From 125b3835e556b6c7d967148f09ed15c0a4747d14 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 26 Sep 2011 08:27:22 -0700 Subject: [PATCH] * floatfns.c (Fexpt): Avoid undefined signed * signed overflow. --- src/ChangeLog | 1 + src/floatfns.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index ff0972fd0f..9857461143 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -286,6 +286,7 @@ (Fdo_auto_save, Fset_buffer_auto_saved) (Fclear_buffer_auto_save_failure): Don't assume time_t is signed, or that it fits in int. + * floatfns.c (Fexpt): Avoid undefined signed * signed overflow. * fns.c (Fcompare_strings, Fstring_lessp, struct textprop_rec, concat) (string_char_byte_cache_charpos, string_char_byte_cache_bytepos) (string_char_to_byte, string_byte_to_char) diff --git a/src/floatfns.c b/src/floatfns.c index 2011b4d942..6158b9bd26 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -484,7 +484,8 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, && INTEGERP (arg2) /* don't promote, if both are ints, and */ && 0 <= XINT (arg2)) /* we are sure the result is not fractional */ { /* this can be improved by pre-calculating */ - EMACS_INT acc, x, y; /* some binary powers of x then accumulating */ + EMACS_INT y; /* some binary powers of x then accumulating */ + EMACS_UINT acc, x; /* Unsigned so that overflow is well defined. */ Lisp_Object val; x = XINT (arg1); -- 2.20.1