[EditLine] Check string pointers before dereferencing them.

Get*AtIndex() can return nullptr. This only happens in the swift
REPL support, so it's hard to test upstream.

<rdar://problem/50875178>

llvm-svn: 361078
This commit is contained in:
Davide Italiano 2019-05-17 21:49:17 +00:00
parent a9c7b2583f
commit 53f68c5764
1 changed files with 3 additions and 2 deletions

View File

@ -870,10 +870,11 @@ static void PrintCompletion(FILE *output_file, size_t start, size_t end,
const char *completion_str = completions.GetStringAtIndex(i);
const char *description_str = descriptions.GetStringAtIndex(i);
fprintf(output_file, "\n\t%-*s", max_len, completion_str);
if (completion_str)
fprintf(output_file, "\n\t%-*s", max_len, completion_str);
// Print the description if we got one.
if (strlen(description_str))
if (description_str && strlen(description_str))
fprintf(output_file, " -- %s", description_str);
}
}