aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AutoComplete.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index d154a913a..27eed53b9 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -167,7 +167,9 @@ void AutoComplete::SetList(const char *list) {
char item[maxItemLen];
for (size_t i = 0; i < sortMatrix.size(); ++i) {
int wordLen = IndexSort.indices[sortMatrix[i] * 2 + 2] - IndexSort.indices[sortMatrix[i] * 2];
- strncpy(item, list + IndexSort.indices[sortMatrix[i] * 2], wordLen);
+ if (wordLen > maxItemLen-2)
+ wordLen = maxItemLen - 2;
+ memcpy(item, list + IndexSort.indices[sortMatrix[i] * 2], wordLen);
if ((i+1) == sortMatrix.size()) {
// Last item so remove separator if present
if ((wordLen > 0) && (item[wordLen-1] == separator))