From ced026cecc3ab4e888e049d304aa352f9e95152e Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Wed, 19 Nov 2014 23:08:35 +0000 Subject: [PATCH] Support long key names for languages. (bug 6282) --- core/logic/Translator.cpp | 8 ++++++++ core/logic/Translator.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/logic/Translator.cpp b/core/logic/Translator.cpp index a1fdaf42..babe5232 100644 --- a/core/logic/Translator.cpp +++ b/core/logic/Translator.cpp @@ -887,6 +887,14 @@ SMCResult Translator::ReadSMC_LeavingSection(const SMCStates *states) SMCResult Translator::ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value) { + size_t len = strlen(key); + + if (len >= sizeof(((Language *)0)->m_code2)) + { + logger->LogError("[SM] Warning encountered parsing languages.cfg file."); + logger->LogError("[SM] Invalid language code \"%s\" is too long.", key); + } + AddLanguage(key, value); return SMCResult_Continue; diff --git a/core/logic/Translator.h b/core/logic/Translator.h index 8a49eac1..177a2a70 100644 --- a/core/logic/Translator.h +++ b/core/logic/Translator.h @@ -54,7 +54,7 @@ enum PhraseParseState struct Language { - char m_code2[4]; + char m_code2[32]; int m_CanonicalName; };