diff --git a/init/init_parser.cpp b/init/init_parser.cpp index 3ed1d585b..12f44f7cb 100644 --- a/init/init_parser.cpp +++ b/init/init_parser.cpp @@ -315,10 +315,14 @@ static void parse_config(const char *fn, const std::string& data) int nargs = 0; + //TODO: Use a parser with const input and remove this copy + std::vector data_copy(data.begin(), data.end()); + data_copy.push_back('\0'); + parse_state state; state.filename = fn; state.line = 0; - state.ptr = strdup(data.c_str()); // TODO: fix this code! + state.ptr = &data_copy[0]; state.nexttoken = 0; state.parse_line = parse_line_no_op;