Skip to content

Commit

Permalink
- Fix crash bug in localtime_r. If locatime() returns NULL then also …
Browse files Browse the repository at this point in the history
…return

  NULL
  • Loading branch information
zsuraski committed Apr 24, 2000
1 parent dc93a62 commit 9d2738c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main/reentrancy.c
Expand Up @@ -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
Expand Down

0 comments on commit 9d2738c

Please sign in to comment.