From: Paul Eggert Date: Mon, 26 Sep 2011 15:27:22 +0000 (-0700) Subject: * floatfns.c (Fexpt): Avoid undefined signed * signed overflow. X-Git-Tag: emacs-24.2.90~471^2~6^2~187 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=125b3835e556b6c7d967148f09ed15c0a4747d14;p=emacs.git * floatfns.c (Fexpt): Avoid undefined signed * signed overflow. --- diff --git a/src/ChangeLog b/src/ChangeLog index ff0972fd0f1..9857461143a 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 2011b4d942d..6158b9bd26d 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);