Editline: Fix an msan error

Summary:
libedit implementation of el_get(EL_GETTC) had a bug, where it was
consuming vararg arguments until reaching the first null pointer (and
not just two, as documented). This was causing (at least) errors to be
reported when running the tests under msan.

The issue has since been fixed in libedit, but this adds patch adds a
trivial workaround, so that we operate correctly with the libedit
versions which are already out there.

Reviewers: christos, krytarowski, davide

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D61191

llvm-svn: 359449
This commit is contained in:
Pavel Labath 2019-04-29 13:54:12 +00:00
parent 50be573ed2
commit 24d26714e0
1 changed files with 7 additions and 3 deletions

View File

@ -1215,9 +1215,13 @@ void Editline::TerminalSizeChanged() {
if (m_editline != nullptr) {
el_resize(m_editline);
int columns;
// Despite the man page claiming non-zero indicates success, it's actually
// zero
if (el_get(m_editline, EL_GETTC, "co", &columns) == 0) {
// This function is documenting as taking (const char *, void *) for the
// vararg part, but in reality in was consuming arguments until the first
// null pointer. This was fixed in libedit in April 2019
// <http://mail-index.netbsd.org/source-changes/2019/04/26/msg105454.html>,
// but we're keeping the workaround until a version with that fix is more
// widely available.
if (el_get(m_editline, EL_GETTC, "co", &columns, nullptr) == 0) {
m_terminal_width = columns;
if (m_current_line_rows != -1) {
const LineInfoW *info = el_wline(m_editline);