mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-05 06:58:15 +00:00
Avoid memory leak by registering shutdown function exactly 1 time
Fixes #2092
This commit is contained in:
@@ -18,6 +18,11 @@ class XmlScanner
|
||||
|
||||
private static $libxmlDisableEntityLoaderValue;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private static $shutdownRegistered = false;
|
||||
|
||||
public function __construct($pattern = '<!DOCTYPE')
|
||||
{
|
||||
$this->pattern = $pattern;
|
||||
@@ -25,7 +30,10 @@ class XmlScanner
|
||||
$this->disableEntityLoaderCheck();
|
||||
|
||||
// A fatal error will bypass the destructor, so we register a shutdown here
|
||||
register_shutdown_function([__CLASS__, 'shutdown']);
|
||||
if (!self::$shutdownRegistered) {
|
||||
self::$shutdownRegistered = true;
|
||||
register_shutdown_function([__CLASS__, 'shutdown']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance(Reader\IReader $reader)
|
||||
|
||||
Reference in New Issue
Block a user