* alloc.c (staticpro): Avoid buffer overrun on repeated calls.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Jul 2013 17:54:26 +0000 (10:54 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Jul 2013 17:54:26 +0000 (10:54 -0700)
(NSTATICS): Now a constant; doesn't need to be a macro.

src/ChangeLog
src/alloc.c

index 975bcaa..73e24bc 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * alloc.c (staticpro): Avoid buffer overrun on repeated calls.
+       (NSTATICS): Now a constant; doesn't need to be a macro.
+
 2013-07-19  Richard Stallman  <rms@gnu.org>
 
        * coding.c (decode_coding_utf_8): Add simple loop for fast
index 1124574..4c924f7 100644 (file)
@@ -341,7 +341,7 @@ struct gcpro *gcprolist;
 /* Addresses of staticpro'd variables.  Initialize it to a nonzero
    value; otherwise some compilers put it into BSS.  */
 
-#define NSTATICS 0x800
+enum { NSTATICS = 2048 };
 static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag};
 
 /* Index of next unused slot in staticvec.  */
@@ -5136,9 +5136,9 @@ Does not copy symbols.  Copies strings without text properties.  */)
 void
 staticpro (Lisp_Object *varaddress)
 {
-  staticvec[staticidx++] = varaddress;
   if (staticidx >= NSTATICS)
     fatal ("NSTATICS too small; try increasing and recompiling Emacs.");
+  staticvec[staticidx++] = varaddress;
 }
 
 \f