Skip to content

Commit

Permalink
Modifying times function to gracefully handle being passed a null poi…
Browse files Browse the repository at this point in the history
…nter

Signed-off by: Shawn M Barber <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
Shawn Barber' via OSv Development authored and nyh committed Mar 9, 2021
1 parent bd2fa23 commit b49485b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,15 @@ clock_t times(struct tms *buffer)
clockseconds time;
time = duration_cast<clockseconds>(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)
Expand Down

0 comments on commit b49485b

Please sign in to comment.