Copy name in LoadDictionary if not dictionary_name

compiledict.c sets dict_name to dictionary_name if dict_name is
not set, and passes that to LoadDictionary. LoadDictionary then
copies the passed in name to dictionary_name.

This causes -fsanitize=address to fail with overlapping memory
addresses passed to strncpy (copying the string to itself). As
such, don't copy the name in this case.
This commit is contained in:
Reece H. Dunn
2018-03-21 20:37:44 +00:00
parent cd17e7c935
commit b60d2452c3
+2 -1
View File
@@ -212,7 +212,8 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
int size;
char fname[sizeof(path_home)+20];
strncpy(dictionary_name, name, 40); // currently loaded dictionary name
if (dictionary_name != name)
strncpy(dictionary_name, name, 40); // currently loaded dictionary name
strncpy(tr->dictionary_name, name, 40);
// Load a pronunciation data file into memory