* constants.c (set_constant_entry): Allocated cleared memory.
authorTom Tromey <tromey@redhat.com>
Thu, 23 Jan 2003 17:40:42 +0000 (17:40 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 23 Jan 2003 17:40:42 +0000 (17:40 +0000)
From-SVN: r61661

gcc/java/ChangeLog
gcc/java/constants.c

index cf9ce67e6c9c5bcf87fadaf414eae4811e926336..092d5bdc0d6fb3e7ad7b363c29d545920f8183a9 100644 (file)
@@ -1,3 +1,7 @@
+2003-01-23  Tom Tromey  <tromey@redhat.com>
+
+       * constants.c (set_constant_entry): Allocated cleared memory.
+
 2003-01-22  Tom Tromey  <tromey@redhat.com>
 
        * java-tree.h: Don't use PARAMS.
index cdf307c7f6589b163884b6dd31c4da1e7b8c1573..1a56df0646149000ee236bc6243e4cdb2066532e 100644 (file)
@@ -46,12 +46,14 @@ set_constant_entry (CPool *cpool, int index, int tag, jword value)
   if (cpool->data == NULL)
     {
       cpool->capacity = 100;
-      cpool->tags = ggc_alloc (sizeof(uint8) * cpool->capacity);
-      cpool->data = ggc_alloc (sizeof(union cpool_entry) * cpool->capacity);
+      cpool->tags = ggc_alloc_cleared (sizeof(uint8) * cpool->capacity);
+      cpool->data = ggc_alloc_cleared (sizeof(union cpool_entry)
+                                      * cpool->capacity);
       cpool->count = 1;
     }
   if (index >= cpool->capacity)
     {
+      int old_cap = cpool->capacity;
       cpool->capacity *= 2;
       if (index >= cpool->capacity)
        cpool->capacity = index + 10;
@@ -59,6 +61,11 @@ set_constant_entry (CPool *cpool, int index, int tag, jword value)
                                 sizeof(uint8) * cpool->capacity);
       cpool->data = ggc_realloc (cpool->data,
                                 sizeof(union cpool_entry) * cpool->capacity);
+
+      /* Make sure GC never sees uninitialized tag values.  */
+      memset (cpool->tags + old_cap, 0, cpool->capacity - old_cap);
+      memset (cpool->data + old_cap, 0,
+             (cpool->capacity - old_cap) * sizeof (union cpool_entry));
     }
   if (index >= cpool->count)
     cpool->count = index + 1;