From b2ff187803aa089f3e995e1034a6c6b67b197467 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Fri, 26 Jan 2024 18:16:48 +1000 Subject: [PATCH] PRVM: Fix a hack in LNO file loading This caused misaligned memory access. Signed-off-by: bones_was_here --- prvm_edict.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/prvm_edict.c b/prvm_edict.c index c05aaa28..323f40a2 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1973,12 +1973,12 @@ static void PRVM_LoadLNO( prvm_prog_t *prog, const char *progname ) { } header = (unsigned int *) lno; - if( header[ 0 ] == *(unsigned int *) "LNOF" && - LittleLong( header[ 1 ] ) == 1 && - (unsigned int)LittleLong( header[ 2 ] ) == (unsigned int)prog->progs_numglobaldefs && - (unsigned int)LittleLong( header[ 3 ] ) == (unsigned int)prog->progs_numglobals && - (unsigned int)LittleLong( header[ 4 ] ) == (unsigned int)prog->progs_numfielddefs && - (unsigned int)LittleLong( header[ 5 ] ) == (unsigned int)prog->progs_numstatements ) + if (memcmp(lno, "LNOF", 4) == 0 + && LittleLong( header[ 1 ] ) == 1 + && (unsigned int)LittleLong( header[ 2 ] ) == (unsigned int)prog->progs_numglobaldefs + && (unsigned int)LittleLong( header[ 3 ] ) == (unsigned int)prog->progs_numglobals + && (unsigned int)LittleLong( header[ 4 ] ) == (unsigned int)prog->progs_numfielddefs + && (unsigned int)LittleLong( header[ 5 ] ) == (unsigned int)prog->progs_numstatements) { prog->statement_linenums = (int *)Mem_Alloc(prog->progs_mempool, prog->progs_numstatements * sizeof( int ) ); memcpy( prog->statement_linenums, header + 6, prog->progs_numstatements * sizeof( int ) ); -- 2.39.2