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,15 +8726,21 @@ Call_expression::do_get_tree(Translate_context* context) ...@@ -8726,15 +8726,21 @@ Call_expression::do_get_tree(Translate_context* context)
arg_val, arg_val,
location); location);
if (args[i] == error_mark_node) if (args[i] == error_mark_node)
{
delete[] args;
return error_mark_node; return error_mark_node;
} }
}
gcc_assert(pp == params->end()); gcc_assert(pp == params->end());
gcc_assert(i == nargs); gcc_assert(i == nargs);
} }
tree rettype = TREE_TYPE(TREE_TYPE(fntype->get_tree(gogo))); tree rettype = TREE_TYPE(TREE_TYPE(fntype->get_tree(gogo)));
if (rettype == error_mark_node) if (rettype == error_mark_node)
{
delete[] args;
return error_mark_node; return error_mark_node;
}
tree fn; tree fn;
if (has_closure) if (has_closure)
...@@ -8749,7 +8755,10 @@ Call_expression::do_get_tree(Translate_context* context) ...@@ -8749,7 +8755,10 @@ Call_expression::do_get_tree(Translate_context* context)
gcc_unreachable(); gcc_unreachable();
if (fn == error_mark_node || TREE_TYPE(fn) == error_mark_node) if (fn == error_mark_node || TREE_TYPE(fn) == error_mark_node)
{
delete[] args;
return error_mark_node; return error_mark_node;
}
// This is to support builtin math functions when using 80387 math. // This is to support builtin math functions when using 80387 math.
tree fndecl = fn; tree fndecl = fn;
......
...@@ -2832,8 +2832,12 @@ Gogo::call_builtin(tree* pdecl, source_location location, const char* name, ...@@ -2832,8 +2832,12 @@ Gogo::call_builtin(tree* pdecl, source_location location, const char* name,
types[i] = va_arg(ap, tree); types[i] = va_arg(ap, tree);
args[i] = va_arg(ap, tree); args[i] = va_arg(ap, tree);
if (types[i] == error_mark_node || args[i] == error_mark_node) if (types[i] == error_mark_node || args[i] == error_mark_node)
{
delete[] types;
delete[] args;
return error_mark_node; return error_mark_node;
} }
}
va_end(ap); va_end(ap);
if (*pdecl == NULL_TREE) if (*pdecl == NULL_TREE)
......
...@@ -180,16 +180,16 @@ Archive_file::initialize() ...@@ -180,16 +180,16 @@ Archive_file::initialize()
} }
if (filename == "/") if (filename == "/")
{ {
char* buf = new char[size]; char* rdbuf = new char[size];
if (::read(this->fd_, buf, size) != size) if (::read(this->fd_, rdbuf, size) != size)
{ {
error_at(this->location_, "%s: could not read extended names", error_at(this->location_, "%s: could not read extended names",
filename.c_str()); filename.c_str());
delete buf; delete[] rdbuf;
return false; return false;
} }
this->extended_names_.assign(buf, size); this->extended_names_.assign(rdbuf, size);
delete buf; delete[] rdbuf;
} }
return true; return true;
......
...@@ -244,11 +244,13 @@ Import::find_object_export_data(const std::string& filename, ...@@ -244,11 +244,13 @@ Import::find_object_export_data(const std::string& filename,
if (c < 0) if (c < 0)
{ {
error_at(location, "read %s failed: %m", filename.c_str()); error_at(location, "read %s failed: %m", filename.c_str());
delete[] buf;
return NULL; return NULL;
} }
if (c < sec_length) if (c < sec_length)
{ {
error_at(location, "%s: short read", filename.c_str()); error_at(location, "%s: short read", filename.c_str());
delete[] buf;
return NULL; 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