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

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