From 054c0457fd670ab29024e5e8655f507aecd68e18 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 6 Oct 2011 03:18:20 -0400 Subject: [PATCH] Stop crash in OOM handling in NSS --- ChangeLog | 5 +++++ nss/nsswitch.c | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52d4f1c..710d6db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-10-06 Ulrich Drepper + + * nss/nsswitch.c (__nss_lookup_function): Fix order of deleting + from tree and freeing node. + 2011-09-25 Jiri Olsa * nss/nsswitch.c (__nss_database_lookup): Handle diff --git a/nss/nsswitch.c b/nss/nsswitch.c index ac73984..924cc84 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -407,6 +407,7 @@ __nss_lookup_function (service_user *ni, const char *fct_name) /* Oops. We can't instantiate this node properly. Remove it from the tree. */ __tdelete (&fct_name, &ni->known, &known_compare); + free (known); result = NULL; } else @@ -418,11 +419,8 @@ __nss_lookup_function (service_user *ni, const char *fct_name) #if !defined DO_STATIC_NSS || defined SHARED /* Load the appropriate library. */ if (nss_load_library (ni) != 0) - { - /* This only happens when out of memory. */ - free (known); - goto remove_from_tree; - } + /* This only happens when out of memory. */ + goto remove_from_tree; if (ni->library->lib_handle == (void *) -1l) /* Library not found => function not found. */ -- 2.7.4