shithub: libmujs

Download patch

ref: 81d5b30accd3094e8feb44126e4dccf2f6e6c9e3
parent: 7448a82448aa4eff952a4fdb836f197b844e3d1d
author: Tor Andersson <tor.andersson@artifex.com>
date: Fri Oct 26 10:50:20 EDT 2018

Initialize random seed for Math.random().

--- a/jsmath.c
+++ b/jsmath.c
@@ -2,6 +2,8 @@
 #include "jsvalue.h"
 #include "jsbuiltin.h"
 
+#include <time.h>
+
 static void Math_abs(js_State *J)
 {
 	js_pushnumber(J, fabs(js_tonumber(J, 1)));
@@ -138,6 +140,8 @@
 
 void jsB_initmath(js_State *J)
 {
+	srand(time(NULL));
+
 	js_pushobject(J, jsV_newobject(J, JS_CMATH, J->Object_prototype));
 	{
 		jsB_propn(J, "E", 2.7182818284590452354);