From 0b76b4d8c28e8d82422ddeea2cc3c079fe4bb3dc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 24 Oct 2014 18:33:29 +0200 Subject: [PATCH] calendar: make freeing a calendar spec object deal fine with NULL In order to make object destruction easier (in particular in combination with _cleanup_) we usually make destructors deal with NULL objects as NOPs. Change the calendar spec destructor to follow the same scheme. --- src/core/load-fragment.c | 3 +-- src/shared/calendarspec.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 6b6f9908b58..e193a67dcd2 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -1366,8 +1366,7 @@ int config_parse_timer(const char *unit, v = new0(TimerValue, 1); if (!v) { - if (c) - calendar_spec_free(c); + calendar_spec_free(c); return log_oom(); } diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c index 69b74272329..4ac74ab0a20 100644 --- a/src/shared/calendarspec.c +++ b/src/shared/calendarspec.c @@ -35,7 +35,9 @@ static void free_chain(CalendarComponent *c) { } void calendar_spec_free(CalendarSpec *c) { - assert(c); + + if (!c) + return; free_chain(c->year); free_chain(c->month);