diff options
author | Mike Pall <mike> | 2011-06-10 13:47:11 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-06-10 13:47:11 +0200 |
commit | 27d8d3b5d9a8f05336144f85670c0e00d12dc6cd (patch) | |
tree | 76081c6fb530c6e99e4fe0eeb9e18b56e3d561d8 | |
parent | b6a7fc5330040564d507eb836ea524acf1c8a759 (diff) | |
download | luajit-27d8d3b5d9a8f05336144f85670c0e00d12dc6cd.tar.gz luajit-27d8d3b5d9a8f05336144f85670c0e00d12dc6cd.tar.bz2 luajit-27d8d3b5d9a8f05336144f85670c0e00d12dc6cd.zip |
Fix check for missing arguments in string.format().
-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': |