mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Prevent memory leaks in case SeqILU0 throws an exception.
This commit is contained in:
@@ -196,6 +196,11 @@ createILU0Ptr(const M& A, double relax,
|
||||
// Check whether there was a problem on some process
|
||||
if ( comm.communicator().min(ilu_setup_successful) == 0 )
|
||||
{
|
||||
if ( ilu ) // not null if constructor succeeded
|
||||
{
|
||||
// prevent memory leak
|
||||
delete ilu;
|
||||
}
|
||||
throw Dune::MatrixBlockError();
|
||||
}
|
||||
return typename SelectParallelILUSharedPtr<Dune::SeqILU0<M,X,X>, I1, I2>
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Opm
|
||||
const double relax = 1.0;
|
||||
SeqPreconditioner* seq_precond = nullptr;
|
||||
try {
|
||||
seq_precond= new SeqPreconditioner(opA.getmat(),
|
||||
seq_precond = new SeqPreconditioner(opA.getmat(),
|
||||
relax);
|
||||
}
|
||||
catch ( Dune::MatrixBlockError error )
|
||||
@@ -154,6 +154,11 @@ namespace Opm
|
||||
// Check whether there was a problem on some process
|
||||
if ( comm.communicator().min(ilu_setup_successful) == 0 )
|
||||
{
|
||||
if ( seq_precond ) // not null if constructor succeeded
|
||||
{
|
||||
// prevent memory leak
|
||||
delete seq_precond;
|
||||
}
|
||||
throw Dune::MatrixBlockError();
|
||||
}
|
||||
return Pointer(new ParPreconditioner(*seq_precond, comm),
|
||||
|
||||
Reference in New Issue
Block a user