From 9d2738cf1d377bcfb01f27571c0ac99326c33283 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Mon, 24 Apr 2000 16:16:45 +0000 Subject: [PATCH] - Fix crash bug in localtime_r. If locatime() returns NULL then also return NULL --- main/reentrancy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/reentrancy.c b/main/reentrancy.c index c1d1e7400b..2f17e56207 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -91,11 +91,14 @@ PHPAPI struct tm *localtime_r(const time_t *const timep, struct tm *p_tm) local_lock(LOCALTIME_R); tmp = localtime(timep); - memcpy(p_tm, tmp, sizeof(struct tm)); + if (tmp) { + memcpy(p_tm, tmp, sizeof(struct tm)); + tmp = p_tm; + } local_unlock(LOCALTIME_R); - return p_tm; + return tmp; } #endif -- 2.40.0