You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by re...@apache.org on 2007/11/30 01:18:26 UTC
svn commit: r599654 - /httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c
Author: rederpj
Date: Thu Nov 29 16:18:26 2007
New Revision: 599654
URL: http://svn.apache.org/viewvc?rev=599654&view=rev
Log:
Do a better job of checking managing memory during subgroup processing.
Try to be graceful and harmless in cases where we run out of SHM.
Modified:
httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c
Modified: httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c?rev=599654&r1=599653&r2=599654&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c (original)
+++ httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c Thu Nov 29 16:18:26 2007
@@ -145,14 +145,32 @@
int i = 0;
util_compare_subgroup_t *sgl_out = NULL;
- if (!sgl_in) return NULL;
+ if (!sgl_in) {
+ return NULL;
+ }
sgl_out = (util_compare_subgroup_t *) util_ald_alloc(cache, sizeof(util_compare_subgroup_t));
- sgl_out->subgroupDNs = util_ald_alloc(cache, sizeof(char *) * sgl_in->len);
- sgl_out->len = sgl_in->len;
-
- for (i = 0; i < sgl_in->len; i++) {
- sgl_out->subgroupDNs[i] = util_ald_strdup(cache, sgl_in->subgroupDNs[i]);
+ if (sgl_out) {
+ sgl_out->subgroupDNs = util_ald_alloc(cache, sizeof(char *) * sgl_in->len);
+ if (sgl_out->subgroupDNs) {
+ for (i = 0; i < sgl_in->len; i++) {
+ sgl_out->subgroupDNs[i] = util_ald_strdup(cache, sgl_in->subgroupDNs[i]);
+ if (!sgl_out->subgroupDNs[i]) {
+ /* We ran out of SHM, delete the strings we allocated for the SGL */
+ for (i = (i - 1); i >= 0; i--) {
+ util_ald_free(cache, sgl_out->subgroupDNs[i]);
+ }
+ util_ald_free(cache, sgl_out->subgroupDNs);
+ util_ald_free(cache, sgl_out);
+ sgl_out = NULL;
+ break;
+ }
+ }
+ /* We were able to allocate new strings for all the subgroups */
+ if (sgl_out != NULL) {
+ sgl_out->len = sgl_in->len;
+ }
+ }
}
return sgl_out;