From f6e50b555c64832a9455307842a4fadeaa2f84c0 Mon Sep 17 00:00:00 2001 From: Jonathan Albert <47063257+jalbert-dev@users.noreply.github.com> Date: Sat, 15 Aug 2020 23:06:33 -0400 Subject: [PATCH] Fix incorrect OP_CLOSURE decompilation (register C -> Bx) --- luadec/decompile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/luadec/decompile.c b/luadec/decompile.c index b62a9fb..b9698f5 100644 --- a/luadec/decompile.c +++ b/luadec/decompile.c @@ -3047,7 +3047,7 @@ char* ProcessCode(Proto* f, int indent, int func_checking, char* funcnumstr) { int i; int uvn; int cfnum = functionnum; - Proto* cf = f->p[c]; + Proto* cf = f->p[bc]; char* tmpname = (char*)calloc(strlen(funcnumstr) + 64, sizeof(char)); uvn = NUPS(cf); @@ -3123,17 +3123,17 @@ char* ProcessCode(Proto* f, int indent, int func_checking, char* funcnumstr) { if (func_checking) { char* code = NULL; char* newfuncnumstr = (char*)calloc(strlen(funcnumstr) + 12, sizeof(char)); - functionnum = c; - sprintf(newfuncnumstr, "%s_%d", funcnumstr, c); + functionnum = bc; + sprintf(newfuncnumstr, "%s_%d", funcnumstr, functionnum); code = PrintFunctionOnlyParamsAndUpvalues(cf, F->indent, newfuncnumstr); StringBuffer_setBuffer(str, code); } else if (!process_sub) { - StringBuffer_printf(str, "DecompiledFunction_%s_%d", funcnumstr, c); + StringBuffer_printf(str, "DecompiledFunction_%s_%d", funcnumstr, bc); } else { char* code = NULL; char* newfuncnumstr = (char*)calloc(strlen(funcnumstr) + 12, sizeof(char)); - functionnum = c; - sprintf(newfuncnumstr, "%s_%d", funcnumstr, c); + functionnum = bc; + sprintf(newfuncnumstr, "%s_%d", funcnumstr, functionnum); code = ProcessCode(cf, F->indent, 0, newfuncnumstr); StringBuffer_setBuffer(str, code); }