'lua_pushfstring' raises an error if called with invalid format

This commit is contained in:
Roberto Ierusalimschy
2007-12-19 15:24:38 -02:00
parent bc82b4d78a
commit fabdaa37b6

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lobject.c,v 2.25 2007/04/10 12:18:17 roberto Exp roberto $ ** $Id: lobject.c,v 2.26 2007/11/09 18:54:25 roberto Exp roberto $
** Some generic functions over Lua objects ** Some generic functions over Lua objects
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -15,6 +15,7 @@
#include "lua.h" #include "lua.h"
#include "ldebug.h"
#include "ldo.h" #include "ldo.h"
#include "lmem.h" #include "lmem.h"
#include "lobject.h" #include "lobject.h"
@@ -133,11 +134,9 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
break; break;
} }
default: { default: {
char buff[3]; luaG_runerror(L,
buff[0] = '%'; "invalid option " LUA_QL("%%%c") " to " LUA_QL("lua_pushfstring"),
buff[1] = *(e+1); *(e + 1));
buff[2] = '\0';
pushstr(L, buff);
break; break;
} }
} }