diff --git a/lib/common/iso8601.c b/lib/common/iso8601.c index 0b419e69c86..849e472f4bd 100644 --- a/lib/common/iso8601.c +++ b/lib/common/iso8601.c @@ -1925,7 +1925,9 @@ time_to_hr(const crm_time_t *dt) { pcmk__time_hr_t *hr_dt = NULL; - pcmk__assert(dt != NULL); + if (dt == NULL) { + return NULL; + } hr_dt = pcmk__assert_alloc(1, sizeof(pcmk__time_hr_t)); hr_dt->years = dt->years; @@ -1957,7 +1959,12 @@ pcmk__time_hr_now(time_t *epoch) *epoch = tv.tv_sec; } crm_time_set_timet(&dt, &(tv.tv_sec)); + hr = time_to_hr(&dt); + if (hr == NULL) { + return NULL; + } + hr->useconds = tv.tv_nsec / QB_TIME_NS_IN_USEC; return hr; } diff --git a/lib/common/tests/iso8601/pcmk__time_format_hr_test.c b/lib/common/tests/iso8601/pcmk__time_format_hr_test.c index 3b9ad79d362..7d7fc58112a 100644 --- a/lib/common/tests/iso8601/pcmk__time_format_hr_test.c +++ b/lib/common/tests/iso8601/pcmk__time_format_hr_test.c @@ -45,6 +45,8 @@ assert_hr_format(const char *format, const char *expected, pcmk__time_hr_t *hr = TEST_TIME; char *result = NULL; + assert_non_null(hr); + hr->useconds = usec; result = pcmk__time_format_hr(format, hr); pcmk__time_hr_free(hr); diff --git a/lib/lrmd/lrmd_alerts.c b/lib/lrmd/lrmd_alerts.c index 79798425445..8e7cd443d55 100644 --- a/lib/lrmd/lrmd_alerts.c +++ b/lib/lrmd/lrmd_alerts.c @@ -155,6 +155,7 @@ exec_alert_list(lrmd_t *lrmd, const GList *alert_list, if (now == NULL) { now = pcmk__time_hr_now(&epoch); + pcmk__assert(now != NULL); } crm_info("Sending %s alert via %s to %s", kind_s, entry->id, entry->recipient);