[Lldb-commits] [PATCH] D61191: Editline: Fix an msan error

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 26 08:11:32 PDT 2019

labath created this revision.
labath added reviewers: christos, krytarowski, davide.

Despite the documentation for the el_get(EL_GETTC) function claiming the
vararg part is (const char *name, void *value), in reality the function
expects the vararg list to be terminated by a null pointer, which can be
clearly seen by examining the source code. Although this is mostly
bening because the extra values are not used it any way, it still lights
up as an error when running the tests under msan.

Work around this quirk by adding an explicit nullptr to the end of the
argument list.



Index: source/Host/common/Editline.cpp
--- source/Host/common/Editline.cpp
+++ source/Host/common/Editline.cpp
@@ -1215,9 +1215,11 @@
   if (m_editline != nullptr) {
     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) {
+    // Mac man page claims non-zero indicates success, but it's actually
+    // zero. Additionally, all manpages document the varargs part of this
+    // function as (const char *name, void *value), but in reality the source
+    // code expects the vararg list to be terminated by a null pointer.
+    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);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61191.196855.patch
Type: text/x-patch
Size: 937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190426/6d77122c/attachment.bin>

More information about the lldb-commits mailing list