From: bones_was_here Date: Fri, 26 Jan 2024 08:16:48 +0000 (+1000) Subject: PRVM: Fix a hack in LNO file loading X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b2ff187803aa089f3e995e1034a6c6b67b197467;p=xonotic%2Fdarkplaces.git PRVM: Fix a hack in LNO file loading This caused misaligned memory access. Signed-off-by: bones_was_here --- 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 ) );