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

This commit is contained in:
Tor Andersson
2014-01-25 17:51:57 +01:00
parent 9103b4f4de
commit 4ee7ef822d

View File

@@ -79,8 +79,8 @@ static int S_fromCharCode(js_State *J, int argc)
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;