|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79987 Memory leak in SplFileInfo because of missing zend_restore_error_handling()
Submitted: 2020-08-18 08:00 UTC Modified: 2020-08-18 08:00 UTC
From: Assigned: dmitry (profile)
Status: Closed Package: SPL related
PHP Version: 8.0Git-2020-08-18 (Git) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2020-08-18 08:00 UTC]
Some SplFileInfo methods don't restore original error handler in exceptional cases.
This leads to memory leaks.

Test script:
class BadSplFileInfo extends SplFileInfo {
    public function __construct() {
$x = new BadSplFileInfo();
set_error_handler(function ($type, $msg, $file, $line, $context = []) {
    echo "ops\n";
try {
} catch (Throwable $e) {
    echo $e->getMessage() . "\n";

Expected result:
Object not initialized

Actual result:
Object not initialized
Zend/zend_closures.c(479) :  Freeing 0xf3c5d380 (204 bytes)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-18 08:00 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2020-08-18 08:08 UTC]
Automatic comment on behalf of
Log: Fixed bug #79987 (Memory leak in SplFileInfo because of missing zend_restore_error_handling())
 [2020-08-18 08:08 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jan 25 13:01:23 2021 UTC