[systemd-devel] [PATCH] tmpfiles: Fix memory leak in parse_line()
Maciej Wereski
m.wereski at partner.samsung.com
Fri Jul 19 06:43:12 PDT 2013
---
src/tmpfiles/tmpfiles.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 555347a..4a1ce36 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -119,6 +119,14 @@ static const char conf_file_dirs[] =
#define MAX_DEPTH 256
+static void item_free(Item *);
+static inline void item_freep(Item **i) {
+ if (*i)
+ item_free(*i);
+}
+
+#define _cleanup_item_free_ _cleanup_(item_freep)
+
static bool needs_glob(ItemType t) {
return t == IGNORE_PATH || t == IGNORE_DIRECTORY_PATH || t == REMOVE_PATH || t == RECURSIVE_REMOVE_PATH || t == RELABEL_PATH || t == RECURSIVE_RELABEL_PATH;
}
@@ -1013,7 +1021,7 @@ static bool item_equal(Item *a, Item *b) {
}
static int parse_line(const char *fname, unsigned line, const char *buffer) {
- _cleanup_free_ Item *i = NULL;
+ _cleanup_item_free_ Item *i = NULL;
Item *existing;
_cleanup_free_ char
*mode = NULL, *user = NULL, *group = NULL, *age = NULL;
--
1.8.3.3
More information about the systemd-devel
mailing list