diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-01 18:03:26 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-01 18:03:26 +0000 |
commit | b1fc924e524bf68169d22b68b2acef8ca1882e62 (patch) | |
tree | 57674f98cb29f239753d7c9e50143a96835914cf /gcc/emutls.c | |
parent | 7737aadd3692d67f89db63f198e6255e394804e8 (diff) | |
download | gcc-b1fc924e524bf68169d22b68b2acef8ca1882e62.tar.gz |
PR other/40024
* emutls.c (__emutls_get_address): Change arr->size to mean number
of allocated arr->data entries instead of # of slots + 1.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148061 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/emutls.c')
-rw-r--r-- | gcc/emutls.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/emutls.c b/gcc/emutls.c index a9c7cf6954c..b7ee3bdfa7c 100644 --- a/gcc/emutls.c +++ b/gcc/emutls.c @@ -155,23 +155,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); } |