From 60ea38000a97132ae1cfc7d574b081ad5f12b75a Mon Sep 17 00:00:00 2001 From: HarpyWar Date: Thu, 24 Jul 2014 11:22:18 +0400 Subject: [PATCH] fix crash when chatting on moderated channel https://github.com/HarpyWar/pvpgn/issues/68 --- src/bnetd/channel.cpp | 2 +- src/bnetd/i18n.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bnetd/channel.cpp b/src/bnetd/channel.cpp index ed5773f98..fb66e2193 100644 --- a/src/bnetd/channel.cpp +++ b/src/bnetd/channel.cpp @@ -699,7 +699,7 @@ namespace pvpgn if (!((account_is_operator_or_admin(acc, channel_get_name(channel))) || (channel_conn_has_tmpVOICE(channel, me)) || (account_get_auth_voice(acc, channel_get_name(channel)) == 1))) { - message_send_text(me, message_type_error, me, localize(c, "This channel is moderated")); + message_send_text(me, message_type_error, me, localize(me, "This channel is moderated")); return; } } diff --git a/src/bnetd/i18n.cpp b/src/bnetd/i18n.cpp index 73a7e5f98..b98c63413 100644 --- a/src/bnetd/i18n.cpp +++ b/src/bnetd/i18n.cpp @@ -261,14 +261,16 @@ namespace pvpgn extern std::string _localize(t_connection * c, const char * func, const char * fmt, const fmt::ArgList &args) { - const char *format; + const char *format = fmt; std::string output(fmt); t_gamelang lang; + if (!c) { + eventlog(eventlog_level_error, __FUNCTION__, "got bad connection"); + return format; + } try { - format = fmt; - if (lang = conn_get_gamelang_localized(c)) if (!(format = _find_string(fmt, lang))) format = fmt; // if not found use original