From: bones_was_here Date: Wed, 7 Feb 2024 15:11:27 +0000 (+1000) Subject: snd: fix a hard-to-repro segfault when joining a server X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=954fcc4fae8e18e4cb50a7dfafd9446eb239ec39;p=xonotic%2Fdarkplaces.git snd: fix a hard-to-repro segfault when joining a server Closes https://gitlab.com/xonotic/darkplaces/-/issues/356 Signed-off-by: bones_was_here --- diff --git a/snd_main.c b/snd_main.c index 53e4da99..821ed7b4 100644 --- a/snd_main.c +++ b/snd_main.c @@ -1226,7 +1226,7 @@ static void SND_Spatialize_WithSfx(channel_t *ch, qbool isstatic, sfx_t *sfx) { //Con_Printf("-- entnum %i origin %f %f %f neworigin %f %f %f\n", ch->entnum, ch->origin[0], ch->origin[1], ch->origin[2], cl.entities[ch->entnum].state_current.origin[0], cl.entities[ch->entnum].state_current.origin[1], cl.entities[ch->entnum].state_current.origin[2]); - if (ch->entnum > MAX_EDICTS) + if (CLVM_prog->loaded && ch->entnum > MAX_EDICTS) if (!CL_VM_GetEntitySoundOrigin(ch->entnum, ch->origin)) ch->entnum = MAX_EDICTS; // entity was removed, disown sound } @@ -1240,7 +1240,7 @@ static void SND_Spatialize_WithSfx(channel_t *ch, qbool isstatic, sfx_t *sfx) else Matrix4x4_OriginFromMatrix(&cl.entities[ch->entnum].render.matrix, ch->origin); } - else if (cl.csqc_server2csqcentitynumber[ch->entnum]) + else if (CLVM_prog->loaded && cl.csqc_server2csqcentitynumber[ch->entnum]) { //Con_Printf("-- entnum %i (client %i) origin %f %f %f neworigin %f %f %f\n", ch->entnum, cl.csqc_server2csqcentitynumber[ch->entnum], ch->origin[0], ch->origin[1], ch->origin[2], cl.entities[ch->entnum].state_current.origin[0], cl.entities[ch->entnum].state_current.origin[1], cl.entities[ch->entnum].state_current.origin[2]);