diff options
-rw-r--r-- | lstring.c | 2 | ||||
-rw-r--r-- | lvm.c | 2 |
2 files changed, 2 insertions, 2 deletions
@@ -224,7 +224,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { | |||
224 | return internshrstr(L, str, l); | 224 | return internshrstr(L, str, l); |
225 | else { | 225 | else { |
226 | TString *ts; | 226 | TString *ts; |
227 | if (l_unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char))) | 227 | if (l_unlikely(l * sizeof(char) >= (MAX_SIZE - sizeof(TString)))) |
228 | luaM_toobig(L); | 228 | luaM_toobig(L); |
229 | ts = luaS_createlngstrobj(L, l); | 229 | ts = luaS_createlngstrobj(L, l); |
230 | memcpy(getlngstr(ts), str, l * sizeof(char)); | 230 | memcpy(getlngstr(ts), str, l * sizeof(char)); |
@@ -661,7 +661,7 @@ void luaV_concat (lua_State *L, int total) { | |||
661 | /* collect total length and number of strings */ | 661 | /* collect total length and number of strings */ |
662 | for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { | 662 | for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { |
663 | size_t l = tsslen(tsvalue(s2v(top - n - 1))); | 663 | size_t l = tsslen(tsvalue(s2v(top - n - 1))); |
664 | if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) { | 664 | if (l_unlikely(l >= MAX_SIZE - sizeof(TString) - tl)) { |
665 | L->top.p = top - total; /* pop strings to avoid wasting stack */ | 665 | L->top.p = top - total; /* pop strings to avoid wasting stack */ |
666 | luaG_runerror(L, "string length overflow"); | 666 | luaG_runerror(L, "string length overflow"); |
667 | } | 667 | } |