1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-05 16:55:50 +03:00

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.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@599654 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Paul J. Reder
2007-11-30 00:18:26 +00:00
parent 9a99383c08
commit f591ec6b8d

View File

@@ -145,14 +145,32 @@ util_compare_subgroup_t *util_ald_sgl_dup(util_ald_cache_t *cache, util_compare_
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;