2
1

lua-bug7-string_format.patch 650 B

1234567891011121314151617181920
  1. --- lua-5.1.4.orig/src/lstrlib.c 2008/07/11 17:27:21 1.132.1.4
  2. +++ lua-5.1.4/src/lstrlib.c 2010/05/14 15:12:53
  3. @@ -754,6 +754,7 @@
  4. static int str_format (lua_State *L) {
  5. + int top = lua_gettop(L);
  6. int arg = 1;
  7. size_t sfl;
  8. const char *strfrmt = luaL_checklstring(L, arg, &sfl);
  9. @@ -768,7 +769,8 @@
  10. else { /* format item */
  11. char form[MAX_FORMAT]; /* to store the format (`%...') */
  12. char buff[MAX_ITEM]; /* to store the formatted item */
  13. - arg++;
  14. + if (++arg > top)
  15. + luaL_argerror(L, arg, "no value");
  16. strfrmt = scanformat(L, strfrmt, form);
  17. switch (*strfrmt++) {
  18. case 'c': {