diff options
Diffstat (limited to 'libc/misc/internals')
-rw-r--r-- | libc/misc/internals/parse_config.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libc/misc/internals/parse_config.c b/libc/misc/internals/parse_config.c index c17d25553..4d21b5eec 100644 --- a/libc/misc/internals/parse_config.c +++ b/libc/misc/internals/parse_config.c @@ -75,8 +75,8 @@ static off_t bb_get_chunk_with_continuation(parser_t* parsr) else break; } else if (parsr->allocated) { - parsr->line_len += PAGE_SIZE; - parsr->data = realloc(parsr->data, + parsr->line_len += PAGE_SIZE; + parsr->data = realloc(parsr->data, parsr->data_len + parsr->line_len); parsr->line = parsr->data + parsr->data_len; } else { @@ -206,8 +206,6 @@ again: len = bb_get_chunk_with_continuation(parser); if (len == -1) return 0; - *tokens = (char **) parser->data; - memset(*tokens, 0, sizeof(*tokens[0]) * ntokens); line = parser->line; /* Skip multiple token-delimiters in the start of line? */ @@ -217,6 +215,9 @@ again: if (line[0] == '\0' || line[0] == delims[0]) goto again; + *tokens = (char **) parser->data; + memset(*tokens, 0, sizeof(*tokens[0]) * ntokens); + /* Tokenize the line */ for (t = 0; *line && *line != delims[0] && t < ntokens; t++) { /* Pin token */ |