diff options
Diffstat (limited to 'lstrlib.c')
-rw-r--r-- | lstrlib.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -181,7 +181,7 @@ static int str_byte (lua_State *L) { | |||
181 | size_t pose = getendpos(L, 3, pi, l); | 181 | size_t pose = getendpos(L, 3, pi, l); |
182 | int n, i; | 182 | int n, i; |
183 | if (posi > pose) return 0; /* empty interval; return no values */ | 183 | if (posi > pose) return 0; /* empty interval; return no values */ |
184 | if (pose - posi >= INT_MAX) /* arithmetic overflow? */ | 184 | if (pose - posi >= (size_t)INT_MAX) /* arithmetic overflow? */ |
185 | return luaL_error(L, "string slice too long"); | 185 | return luaL_error(L, "string slice too long"); |
186 | n = (int)(pose - posi) + 1; | 186 | n = (int)(pose - posi) + 1; |
187 | luaL_checkstack(L, n, "string slice too long"); | 187 | luaL_checkstack(L, n, "string slice too long"); |
@@ -1159,7 +1159,7 @@ static int str_format (lua_State *L) { | |||
1159 | char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ | 1159 | char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ |
1160 | int nb = 0; /* number of bytes in added item */ | 1160 | int nb = 0; /* number of bytes in added item */ |
1161 | if (++arg > top) | 1161 | if (++arg > top) |
1162 | luaL_argerror(L, arg, "no value"); | 1162 | return luaL_argerror(L, arg, "no value"); |
1163 | strfrmt = scanformat(L, strfrmt, form); | 1163 | strfrmt = scanformat(L, strfrmt, form); |
1164 | switch (*strfrmt++) { | 1164 | switch (*strfrmt++) { |
1165 | case 'c': { | 1165 | case 'c': { |
@@ -1186,6 +1186,8 @@ static int str_format (lua_State *L) { | |||
1186 | break; | 1186 | break; |
1187 | } | 1187 | } |
1188 | case 'q': { | 1188 | case 'q': { |
1189 | if (form[2] != '\0') /* modifiers? */ | ||
1190 | return luaL_error(L, "specifier '%%q' cannot have modifiers"); | ||
1189 | addliteral(L, &b, arg); | 1191 | addliteral(L, &b, arg); |
1190 | break; | 1192 | break; |
1191 | } | 1193 | } |