Avoid memory leak by registering shutdown function exactly 1 time
Fixes #2092
This commit is contained in:
parent
b01a485f4f
commit
09b979defa
|
|
@ -18,6 +18,11 @@ class XmlScanner
|
||||||
|
|
||||||
private static $libxmlDisableEntityLoaderValue;
|
private static $libxmlDisableEntityLoaderValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static $shutdownRegistered = false;
|
||||||
|
|
||||||
public function __construct($pattern = '<!DOCTYPE')
|
public function __construct($pattern = '<!DOCTYPE')
|
||||||
{
|
{
|
||||||
$this->pattern = $pattern;
|
$this->pattern = $pattern;
|
||||||
|
|
@ -25,7 +30,10 @@ class XmlScanner
|
||||||
$this->disableEntityLoaderCheck();
|
$this->disableEntityLoaderCheck();
|
||||||
|
|
||||||
// A fatal error will bypass the destructor, so we register a shutdown here
|
// 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)
|
public static function getInstance(Reader\IReader $reader)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue