Blame SOURCES/0013-Issue-50984-Memory-leaks-in-disk-monitoring.patch

d69b2b
From a720e002751815323a295e11e77c56d7ce38314e Mon Sep 17 00:00:00 2001
d69b2b
From: Simon Pichugin <spichugi@redhat.com>
d69b2b
Date: Fri, 27 Mar 2020 11:35:55 +0100
d69b2b
Subject: [PATCH] Issue 50984 - Memory leaks in disk monitoring
d69b2b
d69b2b
Description: Reset dirs pointer every time we free it.
d69b2b
The code may be changed in the future so we should make it
d69b2b
more robust.
d69b2b
d69b2b
https://pagure.io/389-ds-base/issue/50984
d69b2b
d69b2b
Reviewed by: spichugi, tbordaz (one line commit rule)
d69b2b
---
d69b2b
 ldap/servers/slapd/daemon.c | 2 ++
d69b2b
 ldap/servers/slapd/main.c   | 1 +
d69b2b
 2 files changed, 3 insertions(+)
d69b2b
d69b2b
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
d69b2b
index 542d31037..a70f40316 100644
d69b2b
--- a/ldap/servers/slapd/daemon.c
d69b2b
+++ b/ldap/servers/slapd/daemon.c
d69b2b
@@ -613,6 +613,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused)))
d69b2b
                         }
d69b2b
                     }
d69b2b
                     slapi_ch_array_free(dirs);
d69b2b
+                    dirs = NULL;
d69b2b
                     return;
d69b2b
                 }
d69b2b
                 /*
d69b2b
@@ -712,6 +713,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused)))
d69b2b
             }
d69b2b
         }
d69b2b
         slapi_ch_array_free(dirs);
d69b2b
+        dirs = NULL; /* now it is not needed but the code may be changed in the future and it'd better be more robust */
d69b2b
         g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL);
d69b2b
         return;
d69b2b
 }
d69b2b
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
d69b2b
index 1f8b01959..e54b8e1c5 100644
d69b2b
--- a/ldap/servers/slapd/main.c
d69b2b
+++ b/ldap/servers/slapd/main.c
d69b2b
@@ -958,6 +958,7 @@ main(int argc, char **argv)
d69b2b
             goto cleanup;
d69b2b
         }
d69b2b
         slapi_ch_array_free(dirs);
d69b2b
+        dirs = NULL;
d69b2b
     }
d69b2b
     /* log the max fd limit as it is typically set in env/systemd */
d69b2b
     slapi_log_err(SLAPI_LOG_INFO, "main",
d69b2b
-- 
d69b2b
2.26.2
d69b2b