functions "luaI_free" and "luaI_realloc" (or macro "growvector") may be

called with NULL.
This commit is contained in:
Roberto Ierusalimschy
1996-02-22 17:34:33 -03:00
parent 05caf09a36
commit 8c1a9899d4
6 changed files with 33 additions and 57 deletions

17
func.c
View File

@@ -42,8 +42,7 @@ void luaI_insertfunction (TFunc *f)
static void freefunc (TFunc *f)
{
luaI_free (f->code);
if (f->locvars)
luaI_free (f->locvars);
luaI_free (f->locvars);
luaI_free (f);
}
@@ -100,16 +99,10 @@ void lua_funcinfo (lua_Object func, char **filename, int *linedefined)
void luaI_registerlocalvar (TaggedString *varname, int line)
{
if (numcurrvars >= maxcurrvars)
if (currvars == NULL)
{
maxcurrvars = LOCALVARINITSIZE;
currvars = newvector (maxcurrvars, LocVar);
}
else
{
maxcurrvars *= 2;
currvars = growvector (currvars, maxcurrvars, LocVar);
}
{
maxcurrvars = (maxcurrvars == 0) ? LOCALVARINITSIZE : maxcurrvars*2;
currvars = growvector(currvars, maxcurrvars, LocVar);
}
currvars[numcurrvars].varname = varname;
currvars[numcurrvars].line = line;
numcurrvars++;