]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
PRVM: Fix a hack in LNO file loading
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 26 Jan 2024 08:16:48 +0000 (18:16 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Mon, 29 Jan 2024 15:27:10 +0000 (01:27 +1000)
This caused misaligned memory access.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
prvm_edict.c

index c05aaa28559b6786be56f8614c15fe970ddcb488..323f40a25583574fc421c409edc74653609d0752 100644 (file)
@@ -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 ) );