1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-04 18:48:24 +01:00

PrimeField: plug memory leaks

This commit is contained in:
terrafrost 2021-07-07 22:30:43 -05:00
parent 8186db7533
commit 05539a72be
2 changed files with 17 additions and 0 deletions

View File

@ -111,4 +111,12 @@ class PrimeField extends FiniteField
{
return Integer::getModulo($this->instanceID)->getLength();
}
/**
* Destructor
*/
public function __destruct()
{
Integer::cleanupCache($this->instanceID);
}
}

View File

@ -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
*