[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
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp
index da83de6..aa52b4c 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -870,10 +870,11 @@
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);
}
}