@@ -81,7 +81,7 @@ static void LoadTranslationOrTT(const TCHAR *__restrict__ ini, const TCHAR * __r
8181 if (!ret )
8282 tsection [0 ] = tsection [1 ] = TEXT ('\0' );
8383
84- if (!l10n_ini ) l10n_ini = (struct strings * )calloc (1 , sizeof (struct strings ));
84+ if (!l10n_ini ) { l10n_ini = (struct strings * )calloc (1 , sizeof (struct strings )); }
8585 if (!l10n_ini ) return ; // Unable to allocate mem
8686
8787 for (i = 0 ; i < ARR_SZ (l10n_inimapping ); i ++ ) {
@@ -136,7 +136,7 @@ void ListAllTranslations()
136136 // First element
137137 langinfo = (struct langinfoitem * )malloc ( sizeof (struct langinfoitem ) );
138138 if (!langinfo ) return ;
139- langinfo [0 ].code = en_US .Code ;
139+ lstrcpy_s ( langinfo [0 ].code , ARR_SZ ( langinfo [ 0 ]. code ), en_US .Code ) ;
140140 langinfo [0 ].lang_english = en_US .LangEnglish ;
141141 langinfo [0 ].lang = en_US .Lang ;
142142 langinfo [0 ].author = en_US .Author ;
@@ -167,9 +167,7 @@ void ListAllTranslations()
167167
168168 // Short language code such as en-US, fr-FR, it-IT etc.
169169 txt = GetSectionOptionCStr (tsection , "Code" , TEXT ("" ));
170- langinfo [n ].code = (TCHAR * )calloc (lstrlen (txt )+ 1 , sizeof (TCHAR ));
171- if (!langinfo [n ].code ) break ;
172- lstrcpy (langinfo [n ].code , txt );
170+ lstrcpy_s (langinfo [n ].code , ARR_SZ (langinfo [n ].code ), txt );
173171
174172 // Language name in English
175173 txt = GetSectionOptionCStr (tsection , "LangEnglish" , TEXT ("" ));
@@ -241,7 +239,6 @@ void FreeAllLangRelated()
241239{
242240 if (langinfo ) {
243241 for (int i = 1 ; i < nlanguages ; i ++ ) {
244- free (langinfo [i ].code );
245242 free (langinfo [i ].lang_english );
246243 free (langinfo [i ].lang );
247244 free (langinfo [i ].author );
0 commit comments