Repository navigation
Conversation
`Discord_Initialize()` returns early when `discord_rpc_inst` is NULL, then allocates it below that check. Because of the early return, the allocation is unreachable, and `discord_rpc_inst` is not initialized. `discord_rpc_create()` never runs at all, `discord_rpc_inst_valid` stays false, and every `discord_update_connection()` returns before `discord_pipe_open()` is reached. Presence could not initialise in any build with HAVE_DISCORD, rendering the whole feature nonfunctional. Remove the early return (the check further down already handles failure).
Author
|
I'm not sure if editing the body after opening the PR does a ping, so just in case it didnt (sorry) - pinging discord.c contributor @LibretroAdmin for review |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Discord_Initialize()returns early whendiscord_rpc_instis NULL, then allocates it below that check.Because of the early return, the allocation is unreachable, and
discord_rpc_instis not initialized.discord_rpc_create()never runs at all,discord_rpc_inst_validstays false, and everydiscord_update_connection()returns beforediscord_pipe_open()is reached. Presence could not initialize at all, rendering the whole feature nonfunctional.Discord_Initialize()has one caller:discord_init()viaCMD_EVENT_DISCORD_INITNothing else assigns that pointer, so this is not configuration- or platform-specific.
Cause
Introduced in 7f64df9, which turned the RPC instance into a pointer and placed the NULL check above the allocation that sets it. Presence has been dead in every build with
HAVE_DISCORDsince.Testing
HAVE_DISCORD = 1and ran against a listener bound at$XDG_RUNTIME_DIR/discord-ipc-0discord_pipe_open()is never called.Discord_Shutdown()still allocates and re-validates cleanlyPinging @LibretroAdmin
Fixes #20096