[Lldb-commits] [PATCH] D42339: Fix uninitialized variable in GoParser

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Jan 20 13:52:09 PST 2018


teemperor created this revision.
teemperor added a reviewer: ribrdb.
teemperor edited the summary of this revision.

`m_last_tok` isn't initialized anywhere before it's used the first time (most likely in the `GoParser::Rule::error` method), which causes most of the GoParser tests to fail with sanitizers enabled with errors like this:

  GoParser.cpp:52:21: runtime error: load of value <random value>, which is not a valid value for type 'GoLexer::TokenType'
  UndefinedBehaviorSanitizer: undefined-behavior GoParser.cpp:52:21


https://reviews.llvm.org/D42339

Files:
  source/Plugins/ExpressionParser/Go/GoParser.cpp


Index: source/Plugins/ExpressionParser/Go/GoParser.cpp
===================================================================
--- source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -67,7 +67,9 @@
   size_t m_pos;
 };
 
-GoParser::GoParser(const char *src) : m_lexer(src), m_pos(0), m_failed(false) {}
+GoParser::GoParser(const char *src)
+    : m_lexer(src), m_pos(0), m_last_tok(GoLexer::TOK_INVALID),
+      m_failed(false) {}
 
 GoASTStmt *GoParser::Statement() {
   Rule r("Statement", this);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42339.130779.patch
Type: text/x-patch
Size: 546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180120/ec7aabcc/attachment.bin>


More information about the lldb-commits mailing list