diff --git a/phpseclib/Math/PrimeField.php b/phpseclib/Math/PrimeField.php index 6b85c724..7e15f906 100644 --- a/phpseclib/Math/PrimeField.php +++ b/phpseclib/Math/PrimeField.php @@ -111,4 +111,12 @@ class PrimeField extends FiniteField { return Integer::getModulo($this->instanceID)->getLength(); } + + /** + * Destructor + */ + public function __destruct() + { + Integer::cleanupCache($this->instanceID); + } } \ No newline at end of file diff --git a/phpseclib/Math/PrimeField/Integer.php b/phpseclib/Math/PrimeField/Integer.php index c274ff64..c933f5c1 100644 --- a/phpseclib/Math/PrimeField/Integer.php +++ b/phpseclib/Math/PrimeField/Integer.php @@ -95,6 +95,15 @@ class Integer extends Base } } + /** + * Delete the modulo for a given instance + */ + public static function cleanupCache($instanceID) + { + unset(static::$modulo[$instanceID]); + unset(static::$reduce[$instanceID]); + } + /** * Returns the modulo *