about summary refs log tree commit diff
path: root/sysdeps/generic/dl-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic/dl-cache.c')
-rw-r--r--sysdeps/generic/dl-cache.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sysdeps/generic/dl-cache.c b/sysdeps/generic/dl-cache.c
index 36d6c707d3..8eb18b79cc 100644
--- a/sysdeps/generic/dl-cache.c
+++ b/sysdeps/generic/dl-cache.c
@@ -1,5 +1,5 @@
 /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -88,13 +88,16 @@ _dl_load_cache_lookup (const char *name)
 	! strcmp (name, ((const char *) &cache->libs[cache->nlibs] +
 			 cache->libs[i].key)))
       {
-	best = ((const char *) &cache->libs[cache->nlibs]
-		+ cache->libs[i].value);
+	if ((best == NULL) || (cache->libs[i].flags == 3))
+	  {
+	    best = ((const char *) &cache->libs[cache->nlibs]
+		    + cache->libs[i].value);
 
-	if (cache->libs[i].flags == 3)
-	  /* We've found an exact match for the shared object and no
-	     general `ELF' release.  Stop searching.  */
-	  break;
+	    if (cache->libs[i].flags == 3)
+	      /* We've found an exact match for the shared object and no
+		 general `ELF' release.  Stop searching.  */
+	      break;
+	  }
       }
   return best;
 }