* floatfns.c (Fexpt): Avoid undefined signed * signed overflow.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 26 Sep 2011 15:27:22 +0000 (08:27 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 26 Sep 2011 15:27:22 +0000 (08:27 -0700)
src/ChangeLog
src/floatfns.c

index ff0972f..9857461 100644 (file)
        (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)
index 2011b4d..6158b9b 100644 (file)
@@ -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);