libposix: POSIX_gettimeofday fails without proper initialization

This commit is contained in:
Giacomo Tesio 2017-08-25 23:43:14 +02:00
parent 0185e3b4a1
commit 386cb370a6
1 changed files with 4 additions and 0 deletions

View File

@ -37,11 +37,15 @@ POSIX_gettimeofday(int *errnop, void *timeval, void *timezone)
t = localtime(time(nil));
if(timeval != nil){
if(__libposix_timeval_reader == nil)
sysfatal("libposix: uninitialzed timeval reader");
e = __libposix_timeval_reader(timeval, t);
if(e != 0)
goto FailWithError;
}
if(timezone != nil){
if(__libposix_timezone_reader == nil)
sysfatal("libposix: uninitialzed timezone reader");
e = __libposix_timezone_reader(timezone, t);
if(e != 0)
goto FailWithError;