chiark / gitweb /
calendar: make freeing a calendar spec object deal fine with NULL
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Oct 2014 16:33:29 +0000 (18:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 24 Oct 2014 16:33:29 +0000 (18:33 +0200)
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
src/shared/calendarspec.c

index 6b6f990..e193a67 100644 (file)
@@ -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();
         }
 
index 69b7427..4ac74ab 100644 (file)
@@ -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);