summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/reentrancy.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/main/reentrancy.c b/main/reentrancy.c
index 00bd0c97f2..027bb8c8a4 100644
--- a/main/reentrancy.c
+++ b/main/reentrancy.c
@@ -205,11 +205,14 @@ PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm)
local_lock(GMTIME_R);
tmp = gmtime(timep);
- memcpy(p_tm, tmp, sizeof(struct tm));
+ if (tmp) {
+ memcpy(p_tm, tmp, sizeof(struct tm));
+ tmp = p_tm;
+ }
local_unlock(GMTIME_R);
- return p_tm;
+ return tmp;
}
#endif