diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2015-11-25 15:17:19 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2015-11-25 15:17:19 -0700 |
| commit | a600df073a9d1d1ebc166fb02582836f597a7f8f (patch) | |
| tree | c3f2762b3fb67b71fb58936e06d93ca3f63d082b /src/parser.cpp | |
| parent | 0b59afec56ab62b58329b17581eaf166eb28e2c2 (diff) | |
| download | zig-a600df073a9d1d1ebc166fb02582836f597a7f8f.tar.gz zig-a600df073a9d1d1ebc166fb02582836f597a7f8f.zip | |
fix invalid memory write
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 1b256c8513..49f92a9fb1 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -181,8 +181,7 @@ static AstNode *ast_create_node(NodeType type, Token *first_token) { } static AstNode *ast_create_node_with_node(NodeType type, AstNode *other_node) { - AstNode *node = allocate<AstNode>(1); - node->type = type; + AstNode *node = ast_create_node_no_line_info(type); node->line = other_node->line; node->column = other_node->column; return node; @@ -202,8 +201,10 @@ static void ast_buf_from_token(ParseContext *pc, Token *token, Buf *buf) { static void parse_string_literal(ParseContext *pc, Token *token, Buf *buf) { // skip the double quotes at beginning and end // convert escape sequences + + buf_resize(buf, 0); bool escape = false; - for (int i = token->start_pos; i < token->end_pos - 1; i += 1) { + for (int i = token->start_pos + 1; i < token->end_pos - 1; i += 1) { uint8_t c = *((uint8_t*)buf_ptr(pc->buf) + i); if (escape) { switch (c) { |
