Skip to content

Commit 88e9c37

Browse files
committed
Initialize the timeval struct fields, because the gettimeofday() may not fill these.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
1 parent 3de4170 commit 88e9c37

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

targets/default/jerry-port-default-date.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
2828
struct timeval tv;
2929
struct timezone tz;
3030

31+
/* gettimeofday may not fill tv, so zero-initializing */
32+
tv.tv_sec = 0;
33+
tv.tv_usec = 0;
34+
3135
/* gettimeofday may not fill tz, so zero-initializing */
3236
tz.tz_minuteswest = 0;
3337
tz.tz_dsttime = 0;
@@ -47,6 +51,10 @@ double jerry_port_get_current_time ()
4751
{
4852
struct timeval tv;
4953

54+
/* gettimeofday may not fill tv, so zero-initializing */
55+
tv.tv_sec = 0;
56+
tv.tv_usec = 0;
57+
5058
gettimeofday (&tv, NULL);
5159

5260
return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;

0 commit comments

Comments
 (0)