]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorKai Tietz <kai.tietz@onevision.com>
Sat, 27 Jun 2009 17:50:20 +0000 (17:50 +0000)
committerKai Tietz <ktietz@gcc.gnu.org>
Sat, 27 Jun 2009 17:50:20 +0000 (19:50 +0200)
2009-06-27  Kai Tietz  <kai.tietz@onevision.com>

Merged from trunk rev/148061
2009-06-01  Jakub Jelinek  <jakub@redhat.com>
PR other/40024
* emutls.c (__emutls_get_address): Change arr->size to mean number
of allocated arr->data entries instead of # of slots + 1.

From-SVN: r149015

gcc/ChangeLog
gcc/emutls.c

index 036ca97ebce64e6a5973d7771d36cfd88720e545..2af5b4801242604b91621aefdb3f4ebc1f8618d3 100644 (file)
@@ -1,3 +1,11 @@
+2009-06-27  Kai Tietz  <kai.tietz@onevision.com>
+
+       Merged from trunk rev/148061
+       2009-06-01  Jakub Jelinek  <jakub@redhat.com>
+       PR other/40024
+       * emutls.c (__emutls_get_address): Change arr->size to mean number
+       of allocated arr->data entries instead of # of slots + 1.
+
 2009-06-25  Richard Guenther  <rguenther@suse.de>
 
        * c-parser.c (c_parser_postfix_expression): Fix merge glitch.
index adb682b2a1fa8ae4dd7b8fbcbe5ca70411fb90d6..33c07ebebaff94285e411d8e3d0a372b45215bf1 100644 (file)
@@ -157,23 +157,23 @@ __emutls_get_address (struct __emutls_object *obj)
   if (__builtin_expect (arr == NULL, 0))
     {
       pointer size = offset + 32;
-      arr = calloc (size, sizeof (void *));
+      arr = calloc (size + 1, sizeof (void *));
       if (arr == NULL)
        abort ();
       arr->size = size;
       __gthread_setspecific (emutls_key, (void *) arr);
     }
-  else if (__builtin_expect (offset >= arr->size, 0))
+  else if (__builtin_expect (offset > arr->size, 0))
     {
       pointer orig_size = arr->size;
       pointer size = orig_size * 2;
-      if (offset >= size)
+      if (offset > size)
        size = offset + 32;
-      arr = realloc (arr, size * sizeof (void *));
+      arr = realloc (arr, (size + 1) * sizeof (void *));
       if (arr == NULL)
        abort ();
       arr->size = size;
-      memset (arr->data + orig_size - 1, 0,
+      memset (arr->data + orig_size, 0,
              (size - orig_size) * sizeof (void *));
       __gthread_setspecific (emutls_key, (void *) arr);
     }