Skip to content

Commit

Permalink
Fix uninitialized variable in GoParser
Browse files Browse the repository at this point in the history
Summary:
`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
```

Reviewers: ribrdb, davide, labath

Reviewed By: labath

Subscribers: labath, lldb-commits

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

llvm-svn: 323119
  • Loading branch information
Teemperor committed Jan 22, 2018
1 parent da15b5b commit 57f9b36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp
Expand Up @@ -67,7 +67,9 @@ class GoParser::Rule {
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);
Expand Down

0 comments on commit 57f9b36

Please sign in to comment.