From b5b1995f2925b2f9be4a48304ac97a38f8608648 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 10 Mar 2025 15:21:32 -0300 Subject: Checks for type 'int' added to binary header The structure 'AbsLineInfo' is hard-dumped into binary chunks, and it comprises two 'int' fields. --- ldump.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ldump.c') diff --git a/ldump.c b/ldump.c index 71d9a5b1..54f96674 100644 --- a/ldump.c +++ b/ldump.c @@ -253,16 +253,19 @@ static void dumpFunction (DumpState *D, const Proto *f) { } +#define dumpNumInfo(D, tvar, value) \ + { tvar i = value; dumpByte(D, sizeof(tvar)); dumpVar(D, i); } + + static void dumpHeader (DumpState *D) { dumpLiteral(D, LUA_SIGNATURE); dumpByte(D, LUAC_VERSION); dumpByte(D, LUAC_FORMAT); dumpLiteral(D, LUAC_DATA); - dumpByte(D, sizeof(Instruction)); - dumpByte(D, sizeof(lua_Integer)); - dumpByte(D, sizeof(lua_Number)); - dumpInteger(D, LUAC_INT); - dumpNumber(D, LUAC_NUM); + dumpNumInfo(D, int, LUAC_INT); + dumpNumInfo(D, Instruction, LUAC_INST); + dumpNumInfo(D, lua_Integer, LUAC_INT); + dumpNumInfo(D, lua_Number, LUAC_NUM); } -- cgit v1.2.3-55-g6feb