sztupy / luadec51

Lua Decompiler for Lua version 5.1
MIT License
318 stars 127 forks source link

Crash in AddToTable #7

Open leeonix opened 10 years ago

leeonix commented 10 years ago

i try to decompile a file. but crash at

void AddToTable(Function* F, DecTable * tbl, char *value, char *key)
{
   DecTableItem *item;
   List *type;
   int index;
   if (key == NULL) {
      type = &(tbl->numeric);
      index = tbl->topNumeric;
      tbl->topNumeric++;
   } else {
      type = &(tbl->keyed);
      tbl->used++;
      index = 0;
   }
   item = NewTableItem(value, index, key);  <-- Crach at this
   AddToList(type, (ListItem *) item);
   // FIXME: should work with arrays, too
   if (tbl->keyedSize == tbl->used && tbl->arraySize == 0) {
      PrintTable(F, tbl->reg, 0);
      if (error)
         return;
   }
}

because CloseTable delete a table so index is invaild.

void CloseTable(Function * F, int r)
{
   DecTable *tbl = (DecTable *) PopFromList(&(F->tables));
   if (tbl->reg != r) {
      SET_ERROR(F,"Unhandled construct in table");
      return;
   }
   DeleteTable(tbl);
   F->Rtabl[r] = 0;
}

i upload a file. you can test it.

sztupy commented 9 years ago

Can you upload the file somewhere accessible?

leeonix commented 9 years ago

OMG, u reply me after half a year... i already forget what's going on...