about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2016-05-31 23:15:04 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2016-05-31 23:15:04 +0100
commit64f6edf2280569a49c307350522947d6955ac8d7 (patch)
treecfa1242e2f2bff5867c3d2a66caaeca436204dd6
parent039e8c5ee8b5e23e6031e241ddf202d2a12db3b7 (diff)
parent6899ea11475aca9ca60f77b746fc3b08272481e5 (diff)
downloadklee-64f6edf2280569a49c307350522947d6955ac8d7.tar.gz
Merge pull request #405 from ccadar/times
Fixed the stub for times() not to dereference a NULL pointer when cal…
-rw-r--r--runtime/POSIX/stubs.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/POSIX/stubs.c b/runtime/POSIX/stubs.c
index 99e2e768..b4f31bf7 100644
--- a/runtime/POSIX/stubs.c
+++ b/runtime/POSIX/stubs.c
@@ -174,10 +174,15 @@ time_t time(time_t *t) {
 
 clock_t times(struct tms *buf) {
   /* Fake */
-  buf->tms_utime = 0;
-  buf->tms_stime = 0;
-  buf->tms_cutime = 0;
-  buf->tms_cstime = 0;
+  if (!buf)
+    klee_warning("returning 0\n");
+  else {
+    klee_warning("setting all times to 0 and returning 0\n");
+    buf->tms_utime = 0;
+    buf->tms_stime = 0;
+    buf->tms_cutime = 0;
+    buf->tms_cstime = 0;
+  }
   return 0;
 }