aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2011-12-02 15:36:39 +0100
committerBjörn-Egil Dahlberg <[email protected]>2011-12-08 14:12:01 +0100
commit1d603bc4e80cbb3d23da61a55cee0fb8e67d72fb (patch)
tree62d40346f5299d3a4b6a8310f890d997fafa7100 /erts/emulator/beam
parent42f20932f5b2b8e1eebca47bfe696ab5685ba5f9 (diff)
downloadotp-1d603bc4e80cbb3d23da61a55cee0fb8e67d72fb.tar.gz
otp-1d603bc4e80cbb3d23da61a55cee0fb8e67d72fb.tar.bz2
otp-1d603bc4e80cbb3d23da61a55cee0fb8e67d72fb.zip
Let univ_to_local reflect HAVE localtime_r
Handle error cases when localtime or localtime_r returns null.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/erl_time_sup.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/erts/emulator/beam/erl_time_sup.c b/erts/emulator/beam/erl_time_sup.c
index ab2aa6f5dc..695d08ae2d 100644
--- a/erts/emulator/beam/erl_time_sup.c
+++ b/erts/emulator/beam/erl_time_sup.c
@@ -757,17 +757,20 @@ univ_to_local(Sint *year, Sint *month, Sint *day,
#endif
#ifdef HAVE_LOCALTIME_R
- localtime_r(&the_clock, (tm = &tmbuf));
+ tm = localtime_r(&the_clock, &tmbuf);
#else
tm = localtime(&the_clock);
#endif
- *year = tm->tm_year + 1900;
- *month = tm->tm_mon +1;
- *day = tm->tm_mday;
- *hour = tm->tm_hour;
- *minute = tm->tm_min;
- *second = tm->tm_sec;
- return 1;
+ if (tm) {
+ *year = tm->tm_year + 1900;
+ *month = tm->tm_mon +1;
+ *day = tm->tm_mday;
+ *hour = tm->tm_hour;
+ *minute = tm->tm_min;
+ *second = tm->tm_sec;
+ return 1;
+ }
+ return 0;
}