Bug #1310: Free memory in certain error situations, when a VM is created

This commit is contained in:
Carlos Martín committed 2012-06-18 18:12:28 +02:00
1 parent 4e1a05b67a
commit 4eca161ae0
1 file changed
+27 -5
+27 -5
View File
@@ -379,7 +379,7 @@ int VirtualMachine::parse_context(string& error_str)
else if ( num > 1 )
{
error_str = "Only one CONTEXT attribute can be defined.";
return -1;
goto error_cleanup;
}
context = dynamic_cast<VectorAttribute *>(array_context[0]);
@@ -387,7 +387,7 @@ int VirtualMachine::parse_context(string& error_str)
if ( context == 0 )
{
error_str = "Wrong format for CONTEXT attribute.";
return -1;
goto error_cleanup;
}
str = context->marshall(" @^_^@ ");
@@ -395,7 +395,7 @@ int VirtualMachine::parse_context(string& error_str)
if (str == 0)
{
NebulaLog::log("ONE",Log::ERROR, "Cannot marshall CONTEXT");
return -1;
goto error_cleanup;
}
rc = parse_template_attribute(*str,parsed);
@@ -421,6 +421,17 @@ int VirtualMachine::parse_context(string& error_str)
}
return rc;
error_cleanup:
for (int i = 0; i < num ; i++)
{
if (array_context[i] != 0)
{
delete array_context[i];
}
}
return -1;
}
/* -------------------------------------------------------------------------- */
@@ -489,7 +500,7 @@ int VirtualMachine::parse_requirements(string& error_str)
else if ( num > 1 )
{
error_str = "Only one REQUIREMENTS attribute can be defined.";
return -1;
goto error_cleanup;
}
reqs = dynamic_cast<SingleAttribute *>(array_reqs[0]);
@@ -497,7 +508,7 @@ int VirtualMachine::parse_requirements(string& error_str)
if ( reqs == 0 )
{
error_str = "Wrong format for REQUIREMENTS attribute.";
return -1;
goto error_cleanup;
}
rc = parse_template_attribute(reqs->value(),parsed);
@@ -521,6 +532,17 @@ int VirtualMachine::parse_requirements(string& error_str)
}
return rc;
error_cleanup:
for (int i = 0; i < num ; i++)
{
if (array_reqs[i] != 0)
{
delete array_reqs[i];
}
}
return -1;
}
/* ------------------------------------------------------------------------ */