andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

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

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