Skip to content

Prevent recursion in sm_ServerCommandEx (fixes #967)#2133

Merged
psychonic merged 2 commits intoalliedmodders:masterfrom
ojlanders:master
Apr 18, 2024
Merged

Prevent recursion in sm_ServerCommandEx (fixes #967)#2133
psychonic merged 2 commits intoalliedmodders:masterfrom
ojlanders:master

Conversation

@ojlanders
Copy link
Contributor

@ojlanders ojlanders commented Apr 18, 2024

This fixes the issue with recursive ServerCommandEx in old engine (pre-Nuclear Dawn). The issue was that if ServerCommandEx is called recursively, sm_conhook_start and sm_conhook_stop will be added to the console buffer again. When that happens, it will set g_OriginalSpewOutputFunc to SourcemodSpewOutputFunc because the earlier call set the spew func to SourcemodSpewOutputFunc, and then when a line is printed, SourcemodSpewOutputFunc will call SourcemodSpewOutputFunc indefinitely until the stack overflows (in debug) or you get bored (in release). This patch fixes that by checking if we're already catching spew before adding sm_conhook_start/stop again.

Copy link
Member

@asherkin asherkin left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! It's really nice to see this bug fixed.

@psychonic psychonic merged commit 6cac489 into alliedmodders:master Apr 18, 2024
@psychonic
Copy link
Member

Thanks!

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.

3 participants