From 00340610e70f3651d267a210e2c2914f1102d086 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 24 Mar 2017 11:05:51 +0100 Subject: string.rep: don't repeat if n == 0 --- src/lstrlib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lstrlib.js b/src/lstrlib.js index 4bd8664..3a2ea39 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -668,7 +668,7 @@ const str_rep = function(L) { let n = lauxlib.luaL_checkinteger(L, 2); let sep = lauxlib.luaL_optstring(L, 3, ""); - lapi.lua_pushstring(L, (s + sep).repeat(n - 1) + s); + lapi.lua_pushstring(L, n > 0 ? (s + sep).repeat(n - 1) + s : ""); return 1; }; -- cgit v1.2.3-54-g00ecf