mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
BUG: lua_newtag can be called before luaI_IMtable is initialized.
This commit is contained in:
parent
5d60470508
commit
ae067dcddd
20
fallback.c
20
fallback.c
@ -3,7 +3,7 @@
|
|||||||
** TecCGraf - PUC-Rio
|
** TecCGraf - PUC-Rio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_fallback="$Id: fallback.c,v 1.29 1997/03/19 21:12:34 roberto Exp roberto $";
|
char *rcs_fallback="$Id: fallback.c,v 1.30 1997/03/20 19:20:43 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -174,12 +174,14 @@ static void init_entry (int tag)
|
|||||||
|
|
||||||
void luaI_initfallbacks (void)
|
void luaI_initfallbacks (void)
|
||||||
{
|
{
|
||||||
int i;
|
if (luaI_IMtable == NULL) {
|
||||||
IMtable_size = NUM_TYPES+10;
|
int i;
|
||||||
luaI_IMtable = newvector(IMtable_size, struct IM);
|
IMtable_size = NUM_TYPES+10;
|
||||||
for (i=LUA_T_NIL; i<=LUA_T_USERDATA; i++) {
|
luaI_IMtable = newvector(IMtable_size, struct IM);
|
||||||
luaI_IMtable[-i].tp = (lua_Type)i;
|
for (i=LUA_T_NIL; i<=LUA_T_USERDATA; i++) {
|
||||||
init_entry(i);
|
luaI_IMtable[-i].tp = (lua_Type)i;
|
||||||
|
init_entry(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,9 +189,11 @@ int lua_newtag (char *t)
|
|||||||
{
|
{
|
||||||
int tp;
|
int tp;
|
||||||
--last_tag;
|
--last_tag;
|
||||||
if ((-last_tag) >= IMtable_size)
|
if ((-last_tag) >= IMtable_size) {
|
||||||
|
luaI_initfallbacks();
|
||||||
IMtable_size = growvector(&luaI_IMtable, IMtable_size,
|
IMtable_size = growvector(&luaI_IMtable, IMtable_size,
|
||||||
struct IM, memEM, MAX_INT);
|
struct IM, memEM, MAX_INT);
|
||||||
|
}
|
||||||
tp = -findstring(t, typenames);
|
tp = -findstring(t, typenames);
|
||||||
if (tp == LUA_T_ARRAY || tp == LUA_T_USERDATA)
|
if (tp == LUA_T_ARRAY || tp == LUA_T_USERDATA)
|
||||||
luaI_IMtable[-last_tag].tp = tp;
|
luaI_IMtable[-last_tag].tp = tp;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user