[PATCH] registry: Free memory at the end of each loop run to prevent mem leak

swen swen at linux.ibm.com
Wed Jul 31 10:07:18 UTC 2019


Small patch preventing a memleak.

Passed all gitlab-ci tests and a merge request is created.

https://gitlab.com/samba-team/samba/merge_requests/678

Please review and push if happy.

Thanks for your support in advance.

Cheers Swen

-------------- next part --------------
From dafffb558afdf5c2e2defbe5cee1da55a8b567a1 Mon Sep 17 00:00:00 2001
From: Swen Schillig <swen at linux.ibm.com>
Date: Mon, 29 Jul 2019 15:27:58 +0200
Subject: [PATCH] registry: Free memory at the end of each loop run to prevent
 mem leak

Found during torture test runs with enable address-sanitizer.

Signed-off-by: Swen Schillig <swen at linux.ibm.com>
---
 source4/lib/registry/patchfile_preg.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index ba8ac3a5c38..fd62663d32b 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -372,13 +372,13 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 			callbacks->add_key(callback_data, key);
 			callbacks->set_value(callback_data, key, value_name,
 					     value_type, data);
- 		}
+		}
+		TALLOC_FREE(key);
+		TALLOC_FREE(value_name);
+		data_blob_free(&data);
 	}
 cleanup:
 	close(fd);
-	talloc_free(data.data);
-	talloc_free(key);
-	talloc_free(value_name);
-	talloc_free(buf);
+	TALLOC_FREE(mem_ctx);
 	return ret;
 }
-- 
2.20.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20190731/6ff1ba42/signature.sig>


More information about the samba-technical mailing list