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.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c
index f79c317da8..d10ab8ac65 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -312,7 +312,7 @@ dl_open_worker (void *a)
 	    ++runp;
 	  }
 
-	if (__builtin_expect (cnt + 1 < imap->l_scope_max, 0))
+	if (__builtin_expect (cnt + 1 >= imap->l_scope_max, 0))
 	  {
 	    /* The 'r_scope' array is too small.  Allocate a new one
 	       dynamically.  */
@@ -327,7 +327,7 @@ dl_open_worker (void *a)
 		  _dl_signal_error (ENOMEM, "dlopen", NULL,
 				    N_("cannot create scope list"));
 		imap->l_scope = memcpy (newp, imap->l_scope,
-					cnt * imap->l_scope_max);
+					cnt * sizeof (imap->l_scope[0]));
 	      }
 	    else
 	      {
@@ -339,10 +339,10 @@ dl_open_worker (void *a)
 				    N_("cannot create scope list"));
 		imap->l_scope = newp;
 	      }
-
-	    imap->l_scope[cnt++] = &new->l_searchlist;
-	    imap->l_scope[cnt] = NULL;
 	  }
+
+	imap->l_scope[cnt++] = &new->l_searchlist;
+	imap->l_scope[cnt] = NULL;
       }
 
   /* Run the initializer functions of new objects.  */