This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCHv2 1/3] nss: Handle __tsearch out of memory case in __nss_lookup_function


When tsearch fails to allocate memory, it returns NULL.
Fixing __nss_lookup_function to properly handle this case.

---
2011-09-25  Jiri Olsa  <jolsa@redhat.com>

	* nss/nsswitch.c (__nss_lookup_function): Handle __tsearch
	out of memory case.

diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 6c15c3a..7f8900e 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -384,7 +384,9 @@ __nss_lookup_function (service_user *ni, const char *fct_name)
      will be passed to `known_compare' (above).  */
 
   found = __tsearch (&fct_name, &ni->known, &known_compare);
-  if (*found != &fct_name)
+  if (found == NULL)
+      result = NULL;
+  else if (*found != &fct_name)
     {
       /* The search found an existing structure in the tree.  */
       result = ((known_function *) *found)->fct_ptr;
-- 
1.7.4.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]