Skip to content

Commit

Permalink
ManifestParser constructor accesses its first argument, don't pass NULL
Browse files Browse the repository at this point in the history
The constructor does

  env_ = &state->bindings_;

so env_ is effectively set to offsetof(ManifestParser, bindings_).  This
will blow up if env_ gets dereferenced -- this doesn't seem to happen in
these tests, but it's less confusing with this patch.  Also, passing &state is
consistent with the rest of this test.
  • Loading branch information
nico committed Jan 3, 2013
1 parent 37b5ac7 commit 0fd3797
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/manifest_parser_test.cc
Expand Up @@ -295,7 +295,8 @@ TEST_F(ParserTest, ReservedWords) {

TEST_F(ParserTest, Errors) {
{
ManifestParser parser(NULL, NULL);
State state;
ManifestParser parser(&state, NULL);
string err;
EXPECT_FALSE(parser.ParseTest("foobar", &err));
EXPECT_EQ("input:1: expected '=', got eof\n"
Expand All @@ -305,7 +306,8 @@ TEST_F(ParserTest, Errors) {
}

{
ManifestParser parser(NULL, NULL);
State state;
ManifestParser parser(&state, NULL);
string err;
EXPECT_FALSE(parser.ParseTest("x 3", &err));
EXPECT_EQ("input:1: expected '=', got identifier\n"
Expand All @@ -315,7 +317,8 @@ TEST_F(ParserTest, Errors) {
}

{
ManifestParser parser(NULL, NULL);
State state;
ManifestParser parser(&state, NULL);
string err;
EXPECT_FALSE(parser.ParseTest("x = 3", &err));
EXPECT_EQ("input:1: unexpected EOF\n"
Expand Down

0 comments on commit 0fd3797

Please sign in to comment.