shithub: libmujs

Download patch

ref: 4ee7ef822d1b38c0293f575517d2dd9cf6863c7f
parent: 9103b4f4de07ea9d2470b6b21da0c0a8b8d5a897
author: Tor Andersson <tor@ccxvii.net>
date: Sat Jan 25 12:51:57 EST 2014

Fix off-by-one error in String.fromCharCode().

--- a/jsstring.c
+++ b/jsstring.c
@@ -79,8 +79,8 @@
 	Rune c;
 	char *s = malloc(argc * UTFmax + 1), *p = s;
 	// TODO: guard malloc with try/catch
-	for (i = 0; i <= argc; ++i) {
-		c = js_tointeger(J, i + 1); // TODO: ToUInt16()
+	for (i = 1; i <= argc; ++i) {
+		c = js_tointeger(J, i); // TODO: ToUInt16()
 		p += runetochar(p, &c);
 	}
 	*p = 0;