Commit 6452b112 by Ian Lance Taylor

re PR go/47158 ([cppcheck][PATCH] found a memory leaks in gcc/gcc/go/gofrontend/gogo-tree.cc)

	PR go/47158
	PR go/47159
	PR go/47160
	PR go/47161
Fix space leaks.
Patch from Ettl Martin.

From-SVN: r168504
parent 183440ee
......@@ -8726,7 +8726,10 @@ Call_expression::do_get_tree(Translate_context* context)
arg_val,
location);
if (args[i] == error_mark_node)
return error_mark_node;
{
delete[] args;
return error_mark_node;
}
}
gcc_assert(pp == params->end());
gcc_assert(i == nargs);
......@@ -8734,7 +8737,10 @@ Call_expression::do_get_tree(Translate_context* context)
tree rettype = TREE_TYPE(TREE_TYPE(fntype->get_tree(gogo)));
if (rettype == error_mark_node)
return error_mark_node;
{
delete[] args;
return error_mark_node;
}
tree fn;
if (has_closure)
......@@ -8749,7 +8755,10 @@ Call_expression::do_get_tree(Translate_context* context)
gcc_unreachable();
if (fn == error_mark_node || TREE_TYPE(fn) == error_mark_node)
return error_mark_node;
{
delete[] args;
return error_mark_node;
}
// This is to support builtin math functions when using 80387 math.
tree fndecl = fn;
......
......@@ -2832,7 +2832,11 @@ Gogo::call_builtin(tree* pdecl, source_location location, const char* name,
types[i] = va_arg(ap, tree);
args[i] = va_arg(ap, tree);
if (types[i] == error_mark_node || args[i] == error_mark_node)
return error_mark_node;
{
delete[] types;
delete[] args;
return error_mark_node;
}
}
va_end(ap);
......
......@@ -180,16 +180,16 @@ Archive_file::initialize()
}
if (filename == "/")
{
char* buf = new char[size];
if (::read(this->fd_, buf, size) != size)
char* rdbuf = new char[size];
if (::read(this->fd_, rdbuf, size) != size)
{
error_at(this->location_, "%s: could not read extended names",
filename.c_str());
delete buf;
delete[] rdbuf;
return false;
}
this->extended_names_.assign(buf, size);
delete buf;
this->extended_names_.assign(rdbuf, size);
delete[] rdbuf;
}
return true;
......
......@@ -244,11 +244,13 @@ Import::find_object_export_data(const std::string& filename,
if (c < 0)
{
error_at(location, "read %s failed: %m", filename.c_str());
delete[] buf;
return NULL;
}
if (c < sec_length)
{
error_at(location, "%s: short read", filename.c_str());
delete[] buf;
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment