summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2011-06-10 13:47:11 +0200
committerMike Pall <mike>2011-06-10 13:47:11 +0200
commit27d8d3b5d9a8f05336144f85670c0e00d12dc6cd (patch)
tree76081c6fb530c6e99e4fe0eeb9e18b56e3d561d8
parentb6a7fc5330040564d507eb836ea524acf1c8a759 (diff)
downloadluajit-27d8d3b5d9a8f05336144f85670c0e00d12dc6cd.tar.gz
luajit-27d8d3b5d9a8f05336144f85670c0e00d12dc6cd.tar.bz2
luajit-27d8d3b5d9a8f05336144f85670c0e00d12dc6cd.zip
Fix check for missing arguments in string.format().
-rw-r--r--src/lib_string.c5
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
737LJLIB_CF(string_format) 737LJLIB_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':