diff options
-rw-r--r-- | src/lib_string.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib_string.c b/src/lib_string.c index e2396abb..e54b2d50 100644 --- a/src/lib_string.c +++ b/src/lib_string.c | |||
@@ -736,7 +736,7 @@ static unsigned LUA_INTFRM_T num2uintfrm(lua_State *L, int arg) | |||
736 | 736 | ||
737 | LJLIB_CF(string_format) | 737 | LJLIB_CF(string_format) |
738 | { | 738 | { |
739 | int arg = 1; | 739 | int arg = 1, top = (int)(L->top - L->base); |
740 | GCstr *fmt = lj_lib_checkstr(L, arg); | 740 | GCstr *fmt = lj_lib_checkstr(L, arg); |
741 | const char *strfrmt = strdata(fmt); | 741 | const char *strfrmt = strdata(fmt); |
742 | const char *strfrmt_end = strfrmt + fmt->len; | 742 | const char *strfrmt_end = strfrmt + fmt->len; |
@@ -750,7 +750,8 @@ LJLIB_CF(string_format) | |||
750 | } else { /* format item */ | 750 | } else { /* format item */ |
751 | char form[MAX_FMTSPEC]; /* to store the format (`%...') */ | 751 | char form[MAX_FMTSPEC]; /* to store the format (`%...') */ |
752 | char buff[MAX_FMTITEM]; /* to store the formatted item */ | 752 | char buff[MAX_FMTITEM]; /* to store the formatted item */ |
753 | arg++; | 753 | if (++arg > top) |
754 | luaL_argerror(L, arg, lj_obj_typename[0]); | ||
754 | strfrmt = scanformat(L, strfrmt, form); | 755 | strfrmt = scanformat(L, strfrmt, form); |
755 | switch (*strfrmt++) { | 756 | switch (*strfrmt++) { |
756 | case 'c': | 757 | case 'c': |