Skip to content

[SP/MP] Fix mangling of non-dynamic background music file path from pointer overlap#1334

Open
TwelveEyes wants to merge 1 commit into
JACoders:masterfrom
TwelveEyes:fix-music-loop
Open

[SP/MP] Fix mangling of non-dynamic background music file path from pointer overlap#1334
TwelveEyes wants to merge 1 commit into
JACoders:masterfrom
TwelveEyes:fix-music-loop

Conversation

@TwelveEyes

@TwelveEyes TwelveEyes commented May 29, 2026

Copy link
Copy Markdown
Contributor

Non-dynamic background music (such as in JO's yavin_temple map) is unable to loop after playing once due to file path mangling.

sMusic_BackgroundLoop is passed to S_StartBackgroundTrack_Actual as argument loop (fourth arg) here (line 4815):

OpenJK/code/client/snd_dma.cpp

Lines 4813 to 4816 in 8cce3ea

if (S_FileExists( sTestName ))
{
S_StartBackgroundTrack_Actual( pMusicInfo, qfalse, sMusic_BackgroundLoop, sMusic_BackgroundLoop );
}

This causes a pointer overlap (sMusic_BackgroundLoop and loop point to the same memory address) in Q_Strncpyz in S_StartBackgroundTrack_Actual here (line 4088):

OpenJK/code/client/snd_dma.cpp

Lines 4082 to 4088 in 8cce3ea

static qboolean S_StartBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolean qbDynamic, const char *intro, const char *loop )
{
int len;
char dump[16];
char name[MAX_QPATH];
Q_strncpyz( sMusic_BackgroundLoop, loop, sizeof( sMusic_BackgroundLoop ));

This mangles the path and prevents the music file from being looped (as it can't be found). Adding a pointer comparison stops the overlap operation from mangling the path.

@TwelveEyes TwelveEyes requested a review from a team as a code owner May 29, 2026 08:07

@taysta taysta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed this caused a crash on mac when debugging events logging, I think the CI just failed due to a github outage and will pass if re-ran

@TwelveEyes

Copy link
Copy Markdown
Contributor Author

Noticed this caused a crash on mac when debugging events logging, I think the CI just failed due to a github outage and will pass if re-ran

From the log, it failed at the repo checkout step (it couldn't resolve github.com lol). As you said, just a GitHub hiccup that caused it to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants