]> granicus.if.org Git - apache/commitdiff
* modules/ldap/util_ldap_cache_mgr.c (util_ald_cache_insert): Fix a
authorJoe Orton <jorton@apache.org>
Thu, 28 Jul 2005 10:45:59 +0000 (10:45 +0000)
committerJoe Orton <jorton@apache.org>
Thu, 28 Jul 2005 10:45:59 +0000 (10:45 +0000)
cache corruption case: ensure that there is room in the cache for a
copy of the payload before inserting the node.

PR: 34209

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@225746 13f79535-47bb-0310-9956-ffa450edef68

modules/ldap/util_ldap_cache_mgr.c

index 54021a9f3750c718b941b1b0c2a1802a25ec2e31..794b2f50c3df0ae20bb7b7d0712bd2e335a7a865 100644 (file)
@@ -406,11 +406,18 @@ void *util_ald_cache_insert(util_ald_cache_t *cache, void *payload)
         return NULL;
     }
 
+    /* Take a copy of the payload before proceeeding. */
+    payload = (*cache->copy)(cache, payload);
+    if (!payload) {
+        util_ald_free(cache, node);
+        return NULL;
+    }
+
     /* populate the entry */
     cache->inserts++;
     hashval = (*cache->hash)(payload) % cache->size;
     node->add_time = apr_time_now();
-    node->payload = (*cache->copy)(cache, payload);
+    node->payload = payload;
     node->next = cache->nodes[hashval];
     cache->nodes[hashval] = node;