diff options
author | Bradley Nicholes <bnicholes@apache.org> | 2005-03-09 01:15:01 +0100 |
---|---|---|
committer | Bradley Nicholes <bnicholes@apache.org> | 2005-03-09 01:15:01 +0100 |
commit | a92c5fa98cc822c1e6517b50685611907d0fdf41 (patch) | |
tree | 7474ecd745bf600275bf7b651b251790231a7af7 /modules/ldap/util_ldap_cache.c | |
parent | Add ap_mpm_is_experimental and ap_mpm_is_threaded. Use these instead of chec... (diff) | |
download | apache2-a92c5fa98cc822c1e6517b50685611907d0fdf41.tar.xz apache2-a92c5fa98cc822c1e6517b50685611907d0fdf41.zip |
Keep track of the number of attributes retrieved from LDAP so that all the values can be properly cached even if the value is NULL. [PR 33901]
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@156587 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/ldap/util_ldap_cache.c')
-rw-r--r-- | modules/ldap/util_ldap_cache.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/modules/ldap/util_ldap_cache.c b/modules/ldap/util_ldap_cache.c index 97cb83d613..9adf20a4fa 100644 --- a/modules/ldap/util_ldap_cache.c +++ b/modules/ldap/util_ldap_cache.c @@ -159,18 +159,22 @@ void *util_ldap_search_node_copy(util_ald_cache_t *cache, void *c) /* copy vals */ if (node->vals) { - int k = 0; + int k = node->numvals; int i = 0; - while (node->vals[k++]); if (!(newnode->vals = util_ald_alloc(cache, sizeof(char *) * (k+1)))) { util_ldap_search_node_free(cache, newnode); return NULL; } - while (node->vals[i]) { - if (!(newnode->vals[i] = util_ald_strdup(cache, node->vals[i]))) { - util_ldap_search_node_free(cache, newnode); - return NULL; + newnode->numvals = node->numvals; + for (;k;k--) { + if (node->vals[i]) { + if (!(newnode->vals[i] = util_ald_strdup(cache, node->vals[i]))) { + util_ldap_search_node_free(cache, newnode); + return NULL; + } } + else + newnode->vals[i] = NULL; i++; } } @@ -200,9 +204,12 @@ void util_ldap_search_node_free(util_ald_cache_t *cache, void *n) { int i = 0; util_search_node_t *node = (util_search_node_t *)n; + int k = node->numvals; if (node->vals) { - while (node->vals[i]) { - util_ald_free(cache, node->vals[i++]); + for (;k;k--,i++) { + if (node->vals[i]) { + util_ald_free(cache, node->vals[i]); + } } util_ald_free(cache, node->vals); } |