|
|
1abbee |
From fa5a3a16e94773baf1dce3881d5cfab556b87113 Mon Sep 17 00:00:00 2001
|
|
|
1abbee |
From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez@opensuse.org>
|
|
|
1abbee |
Date: Mon, 11 May 2015 23:30:38 -0300
|
|
|
1abbee |
Subject: [PATCH] core: fix memory leak in manager_run_generators()
|
|
|
1abbee |
|
|
|
1abbee |
If systemd is built with GCC address sanitizer or leak sanitizer
|
|
|
1abbee |
the following memory leak ocurs:
|
|
|
1abbee |
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: =================================================================
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: ==326==ERROR: LeakSanitizer: detected memory leaks
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: Direct leak of 101 byte(s) in 3 object(s) allocated from:
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #0 0x7fd1f504993f in strdup (/usr/lib64/libasan.so.2+0x6293f)
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #1 0x55d6ffac5336 in strv_new_ap src/shared/strv.c:163
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #2 0x55d6ffac56a9 in strv_new src/shared/strv.c:185
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #3 0x55d6ffa80272 in generator_paths src/shared/path-lookup.c:223
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #4 0x55d6ff9bdb0f in manager_run_generators src/core/manager.c:2828
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #5 0x55d6ff9b1a10 in manager_startup src/core/manager.c:1121
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #6 0x55d6ff9a78e3 in main src/core/main.c:1667
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #7 0x7fd1f394e8c4 in __libc_start_main (/lib64/libc.so.6+0x208c4)
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: Direct leak of 29 byte(s) in 1 object(s) allocated from:
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #0 0x7fd1f504993f in strdup (/usr/lib64/libasan.so.2+0x6293f)
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #1 0x55d6ffac5288 in strv_new_ap src/shared/strv.c:152
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #2 0x55d6ffac56a9 in strv_new src/shared/strv.c:185
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #3 0x55d6ffa80272 in generator_paths src/shared/path-lookup.c:223
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #4 0x55d6ff9bdb0f in manager_run_generators src/core/manager.c:2828
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #5 0x55d6ff9b1a10 in manager_startup src/core/manager.c:1121
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #6 0x55d6ff9a78e3 in main src/core/main.c:1667
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: #7 0x7fd1f394e8c4 in __libc_start_main (/lib64/libc.so.6+0x208c4)
|
|
|
1abbee |
May 12 02:02:46 linux.site systemd[326]: SUMMARY: AddressSanitizer: 130 byte(s) leaked in 4 allocation(s).
|
|
|
1abbee |
|
|
|
1abbee |
There is a leak due to the the use of cleanup_free instead
|
|
|
1abbee |
_cleanup_strv_free_
|
|
|
1abbee |
|
|
|
1abbee |
Cherry-picked from: f42348ace7feb2311593b8cf6c876856eecf256a
|
|
|
1abbee |
Related: #1331667
|
|
|
1abbee |
---
|
|
|
1abbee |
src/core/manager.c | 2 +-
|
|
|
1abbee |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
1abbee |
|
|
|
1abbee |
diff --git a/src/core/manager.c b/src/core/manager.c
|
|
|
c62b8e |
index bb5050303c..a1504bf17b 100644
|
|
|
1abbee |
--- a/src/core/manager.c
|
|
|
1abbee |
+++ b/src/core/manager.c
|
|
|
1abbee |
@@ -2827,7 +2827,7 @@ static void trim_generator_dir(Manager *m, char **generator) {
|
|
|
1abbee |
}
|
|
|
1abbee |
|
|
|
1abbee |
static int manager_run_generators(Manager *m) {
|
|
|
1abbee |
- _cleanup_free_ char **paths = NULL;
|
|
|
1abbee |
+ _cleanup_strv_free_ char **paths = NULL;
|
|
|
1abbee |
const char *argv[5];
|
|
|
1abbee |
char **path;
|
|
|
1abbee |
int r;
|