Skip to content

Commit

Permalink
Fix discord json invite formatting
Browse files Browse the repository at this point in the history
fmt::format_to_n doesn't actually null terminate the string, manually null terminate it instead
  • Loading branch information
edo9300 committed Sep 23, 2021
1 parent ea70961 commit 9371cbb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gframe/discord_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ void DiscordWrapper::UpdatePresence(PresenceType type) {
auto CreateSecret = [&secret_buf=secret_buf](bool update) {
if(update) {
auto& secret = ygo::mainGame->dInfo.secret;
fmt::format_to_n(secret_buf, sizeof(secret_buf), "{{\"id\": {},\"addr\" : {},\"port\" : {},\"pass\" : \"{}\" }}",
auto ret = fmt::format_to_n(secret_buf, sizeof(secret_buf) - 1, "{{\"id\": {},\"addr\" : {},\"port\" : {},\"pass\" : \"{}\" }}",
secret.game_id, secret.server_address, secret.server_port, BufferIO::EncodeUTF8(secret.pass));
*ret.out = '\0';
}
return secret_buf;
};
Expand Down

0 comments on commit 9371cbb

Please sign in to comment.