From b49485b8f39b05de20b16280419e1bcfa8911af3 Mon Sep 17 00:00:00 2001 From: Shawn Barber' via OSv Development Date: Tue, 9 Mar 2021 15:30:29 -0500 Subject: [PATCH] Modifying times function to gracefully handle being passed a null pointer Signed-off by: Shawn M Barber Message-Id: <20210309203029.20432-1-shawn.barber@dornerworks.com> --- runtime.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/runtime.cc b/runtime.cc index 7871050473..25ef7ea238 100644 --- a/runtime.cc +++ b/runtime.cc @@ -442,12 +442,15 @@ clock_t times(struct tms *buffer) clockseconds time; time = duration_cast(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec)); - buffer->tms_utime = time.count(); - buffer->tms_stime = 0; - buffer->tms_cutime = 0; - buffer->tms_cstime = 0; - - return buffer->tms_utime; + if (buffer) { + buffer->tms_utime = time.count(); + buffer->tms_stime = 0; + buffer->tms_cutime = 0; + buffer->tms_cstime = 0; + return buffer->tms_utime; + } else { + return time.count(); + } } static int prio_find_thread(sched::thread **th, int which, int id)