mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-14 01:42:01 -05:00
Prevent memory leaks in case SeqILU0 throws an exception.
This commit is contained in:
1 parent
3c1498ce92
commit
32b8ed654e
2 files changed
+11
-1
No files matched your search
@@ -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