|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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: Sun Jun 13 02:01:24 2021 UTC