From 2f86aa05411d0c914200801a2b9683dced7a7f65 Mon Sep 17 00:00:00 2001 From: Zeex Date: Thu, 27 Oct 2022 12:58:01 +0600 Subject: [PATCH] Align library table entires on Big Endian machines Not doing this causes the VM to crash on startup inside amx_Init() when extracting the names of linked libraries from the name table. --- source/amx/amx.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/amx/amx.c b/source/amx/amx.c index 675576f..aec9238 100644 --- a/source/amx/amx.c +++ b/source/amx/amx.c @@ -1041,6 +1041,16 @@ int AMXAPI amx_Init(AMX *amx,void *program) AMX_FUNCSTUB *fs; int i,num; + fs=GETENTRY(hdr,publics,0); + assert(hdr->publics<=hdr->natives); + num=NUMENTRIES(hdr,publics,natives); + for (i=0; iaddress); + if (USENAMETABLE(hdr)) + amx_Align32(&((AMX_FUNCSTUBNT*)fs)->nameofs); + fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize); + } /* for */ + fs=GETENTRY(hdr,natives,0); num=NUMENTRIES(hdr,natives,libraries); for (i=0; idefsize); } /* for */ - fs=GETENTRY(hdr,publics,0); - assert(hdr->publics<=hdr->natives); - num=NUMENTRIES(hdr,publics,natives); + fs=GETENTRY(hdr,libraries,0); + num=NUMENTRIES(hdr,libraries,pubvars); for (i=0; iaddress); if (USENAMETABLE(hdr))