* editfns.c (Finsert_char): Don't dump core with very negative counts.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Jun 2011 17:25:16 +0000 (10:25 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Jun 2011 17:25:16 +0000 (10:25 -0700)
src/ChangeLog
src/editfns.c

index e7ca102..d538173 100644 (file)
@@ -1,5 +1,7 @@
 2011-06-16  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * editfns.c (Finsert_char): Don't dump core with very negative counts.
+
        * insdel.c (replace_range): Fix buf overflow when insbytes < outgoing.
 
        * insdel.c, lisp.h (buffer_overflow): New function.
index dec0133..ab17eda 100644 (file)
@@ -2343,11 +2343,11 @@ from adjoining text, if those properties are sticky.  */)
     len = CHAR_STRING (c, str);
   else
     str[0] = c, len = 1;
+  if (XINT (count) <= 0)
+    return Qnil;
   if (BUF_BYTES_MAX / len < XINT (count))
     buffer_overflow ();
   n = XINT (count) * len;
-  if (n <= 0)
-    return Qnil;
   stringlen = min (n, 256 * len);
   string = (char *) alloca (stringlen);
   for (i = 0; i < stringlen; i++)