OSDN Git Service

Nullptr check for VSyncClient::Wait
authorOkan Arikan <okana@google.com>
Fri, 3 Feb 2017 23:06:35 +0000 (15:06 -0800)
committerOkan Arikan <okana@google.com>
Mon, 6 Feb 2017 18:06:03 +0000 (18:06 +0000)
as the documentation in the header implies

Bug: 34609900
Test: pass nullptr to Wait and observe your code not crashing
Change-Id: Ia3ead8cf3369bddedfca4606d0fa261fd57c281f
(cherry picked from commit a919630f3c7cd3c2ee90ef39cbf8147681dd9be8)

libs/vr/libdisplay/vsync_client.cpp

index a0fb313..c928a08 100644 (file)
@@ -26,7 +26,10 @@ int VSyncClient::Wait(int64_t* timestamp_ns) {
           status.GetErrorMessage().c_str());
     return -status.error();
   }
-  *timestamp_ns = status.get();
+
+  if (timestamp_ns != nullptr) {
+    *timestamp_ns = status.get();
+  }
   return 0;
 }