From 499fd8419bc9b96016a26d9480366b92110884e0 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 22 Apr 2008 16:53:36 +0000 Subject: [PATCH] protect from setting memory size to zero --- idl/GHS3DPlugin_Algorithm.idl | 4 ++-- src/GHS3DPlugin_Hypothesis_i.cxx | 6 ++++++ src/GHS3DPlugin_Hypothesis_i.hxx | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/idl/GHS3DPlugin_Algorithm.idl b/idl/GHS3DPlugin_Algorithm.idl index ec7b0a0..3f02497 100644 --- a/idl/GHS3DPlugin_Algorithm.idl +++ b/idl/GHS3DPlugin_Algorithm.idl @@ -55,14 +55,14 @@ module GHS3DPlugin * Maximal size of memory to be used by the algorithm (in Megabytes). * Negative value means not to use this option */ - void SetMaximumMemory(in short MB); + void SetMaximumMemory(in short MB) raises (SALOME::SALOME_Exception); short GetMaximumMemory(); /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero. * Negative value means not to use this option */ - void SetInitialMemory(in short MB); + void SetInitialMemory(in short MB) raises (SALOME::SALOME_Exception); short GetInitialMemory(); /*! * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium diff --git a/src/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin_Hypothesis_i.cxx index 7d805ca..ccc7f15 100644 --- a/src/GHS3DPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPlugin_Hypothesis_i.cxx @@ -63,7 +63,10 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles() //======================================================================= void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB) + throw ( SALOME::SALOME_Exception ) { + if ( MB == 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); ASSERT(myBaseImpl); this->GetImpl()->SetMaximumMemory(MB); SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )"; @@ -84,7 +87,10 @@ CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory() //======================================================================= void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB) + throw ( SALOME::SALOME_Exception ) { + if ( MB == 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); ASSERT(myBaseImpl); this->GetImpl()->SetInitialMemory(MB); SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )"; diff --git a/src/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin_Hypothesis_i.hxx index 97dc574..d868e24 100644 --- a/src/GHS3DPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPlugin_Hypothesis_i.hxx @@ -58,13 +58,13 @@ class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: /*! * Maximal size of memory to be used by the algorithm (in Megabytes) */ - void SetMaximumMemory(CORBA::Short MB); + void SetMaximumMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); CORBA::Short GetMaximumMemory(); /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero */ - void SetInitialMemory(CORBA::Short MB); + void SetInitialMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); CORBA::Short GetInitialMemory(); /*! * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium -- 2.39.2