Blob Blame History Raw
From 0cd6aca794ccbd064c0609c45f8dc6333ad8ca8a Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Tue, 10 Dec 2013 08:08:35 -0700
Subject: [PATCH 75/78] Ticket #47623 fix memleak caused by 47347

https://fedorahosted.org/389/ticket/47623
Reviewed by: tbordaz, nhosoi (Thanks!)
Branch: 389-ds-base-1.3.1
Fix Description: Create the mutex if it doesn't exist.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 0d4849dd7551347f0e24ac1027f4d0501084dcf3)
(cherry picked from commit 5d3ae5f709964cd7dfb73b631a22389223f5ef25)
(cherry picked from commit 5c649ddacd1d2c11b6e922b29472094b780c2a0e)
---
 ldap/servers/slapd/pagedresults.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index a835d6b..9af5773 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -122,7 +122,6 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
                            sizeof(PagedResults) * maxlen);
             }
             *index = maxlen; /* the first position in the new area */
-            conn->c_pagedresults.prl_list[*index].pr_mutex = PR_NewLock();
         } else {
             for (i = 0; i < conn->c_pagedresults.prl_maxlen; i++) {
                 if (!conn->c_pagedresults.prl_list[i].pr_current_be) {
@@ -131,6 +130,9 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
                 }
             }
         }
+        if (!conn->c_pagedresults.prl_list[*index].pr_mutex) {
+            conn->c_pagedresults.prl_list[*index].pr_mutex = PR_NewLock();
+        }
         conn->c_pagedresults.prl_count++;
     } else {
         /* Repeated paged results request.
-- 
1.8.1.4