about summary refs log tree commit diff
path: root/elf/dl-open.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-open.c')
-rw-r--r--elf/dl-open.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 08efe6958d..0e74996473 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -378,17 +378,19 @@ dl_open_worker (void *a)
 
 	assert (new->l_searchlist.r_list[i]->l_type == lt_loaded);
 
-	/* Find the place in the stv slotinfo list.  */
+	/* Find the place in the dtv slotinfo list.  */
 	listp = GL(dl_tls_dtv_slotinfo_list);
 	prevp = NULL;		/* Needed to shut up gcc.  */
 	do
 	  {
 	    /* Does it fit in the array of this list element?  */
-	    if (idx <= listp->len)
+	    if (idx < listp->len)
 	      break;
+	    idx -= listp->len;
 	    prevp = listp;
+	    listp = listp->next;
 	  }
-	while ((listp = listp->next) != NULL);
+	while (listp != NULL);
 
 	if (listp == NULL)
 	  {