[FFmpeg-devel] [PATCH] lavu/time.c: Fix check for clock_gettime

Marvin Scholz epirat07 at gmail.com
Wed May 22 13:38:06 EEST 2019


According to the documentation [1] when checking for a symbol it
should be explicitly checked against NULL and the function pointer
dereferenced.

[1] https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html#//apple_ref/doc/uid/20002378-106633
---
 libavutil/time.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/time.c b/libavutil/time.c
index afa6658aa6..42a7c1792f 100644
--- a/libavutil/time.c
+++ b/libavutil/time.c
@@ -57,7 +57,7 @@ int64_t av_gettime_relative(void)
 {
 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
 #ifdef __APPLE__
-    if (clock_gettime)
+    if (&clock_gettime != NULL)
 #endif
     {
         struct timespec ts;
@@ -72,7 +72,7 @@ int av_gettime_relative_is_monotonic(void)
 {
 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
 #ifdef __APPLE__
-    if (!clock_gettime)
+    if (&clock_gettime == NULL)
         return 0;
 #endif
     return 1;
-- 
2.19.1



More information about the ffmpeg-devel mailing list