diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-12-30 22:15:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-12-30 22:16:04 +0100 |
commit | 783d2675eff73d1937bf8f78b368b1004c2d28c5 (patch) | |
tree | d463582dec4c7801ca8f31cbcb0af03923a08569 | |
parent | 8b18eb674ce4d14e4819e102a0d6679a0fd2e6ce (diff) |
journal: fix a few bad memory accesses and leaks
-rw-r--r-- | src/journal/journal-rate-limit.c | 2 | ||||
-rw-r--r-- | src/journal/journald.c | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/journal/journal-rate-limit.c b/src/journal/journal-rate-limit.c index f69ab2770f..243ff2a378 100644 --- a/src/journal/journal-rate-limit.c +++ b/src/journal/journal-rate-limit.c @@ -111,6 +111,8 @@ void journal_rate_limit_free(JournalRateLimit *r) { while (r->lru) journal_rate_limit_group_free(r->lru); + + free(r); } static bool journal_rate_limit_group_expired(JournalRateLimitGroup *g, usec_t ts) { diff --git a/src/journal/journald.c b/src/journal/journald.c index b290b5d2c0..8d6b3ab438 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -378,11 +378,22 @@ static char *shortened_cgroup_path(pid_t pid) { if (streq(init_path, "/")) init_path[0] = 0; - if (startswith(process_path, init_path)) - path = process_path + strlen(init_path); - else + if (startswith(process_path, init_path)) { + char *p; + + p = strdup(process_path + strlen(init_path)); + if (!p) { + free(process_path); + free(init_path); + return NULL; + } + path = p; + } else { path = process_path; + process_path = NULL; + } + free(process_path); free(init_path); return path; @@ -544,7 +555,7 @@ static void dispatch_message(Server *s, struct timeval *tv, int priority) { int rl; - char *path, *c; + char *path = NULL, *c; assert(s); assert(iovec || n == 0); @@ -1828,6 +1839,8 @@ static void server_done(Server *s) { if (s->rate_limit) journal_rate_limit_free(s->rate_limit); + + free(s->buffer); } int main(int argc, char *argv[]) { |