A string was not terminated with a NUL.

This commit is contained in:
John Wiegley 2010-05-12 03:12:14 -04:00
parent 04cfa7ab71
commit cb047c013d

View file

@ -46,14 +46,19 @@ void expr_t::parse(std::istream& in, const parse_flags_t& flags,
if (original_string) { if (original_string) {
set_text(*original_string); set_text(*original_string);
} else { }
else if (end_pos > start_pos) {
in.clear(); in.clear();
in.seekg(start_pos, std::ios::beg); in.seekg(start_pos, std::ios::beg);
scoped_array<char> buf scoped_array<char> buf
(new char[static_cast<std::size_t>(end_pos - start_pos) + 1]); (new char[static_cast<std::size_t>(end_pos - start_pos) + 1]);
in.read(buf.get(), end_pos - start_pos); in.read(buf.get(), end_pos - start_pos);
buf[end_pos - start_pos] = '\0';
set_text(buf.get()); set_text(buf.get());
} }
else {
set_text("<stream>");
}
} }
void expr_t::compile(scope_t& scope) void expr_t::compile(scope_t& scope)