php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63121 enchant_broker_free_dict destroys broker resource
Submitted: 2012-09-20 11:11 UTC Modified: 2018-01-02 15:26 UTC
From: robert dot johnson at icap dot com Assigned: cmb (profile)
Status: Closed Package: Enchant related
PHP Version: 5.4.7 OS: Win XP SP 3
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: robert dot johnson at icap dot com
New email:
PHP Version: OS:

 

 [2012-09-20 11:11 UTC] robert dot johnson at icap dot com
Description:
------------
Calling enchant_broker_free_dict destroys the resource created by enchant_broker_init(), instead of just the dictionary resource.

Test script:
---------------
if ( PHP_SAPI != 'cli' )
	header('Content-Type:text/plain;charset=UTF-8');
$r = enchant_broker_init();
debug_zval_dump($r);
$d = enchant_broker_request_pwl_dict($r, 'c:\mydict.dic');
enchant_broker_free_dict($d);
debug_zval_dump($r);
echo "End.\r\n";


Expected result:
----------------
resource(1) of type (enchant_broker) refcount(2)
resource(1) of type (enchant_broker) refcount(2)
End.

Actual result:
--------------
resource(1) of type (enchant_broker) refcount(2)
resource(1) of type (Unknown) refcount(2)
End.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-20 11:22 UTC] robert dot johnson at icap dot com
This code works, so bug is probably related to function enchant_broker_request_pwl_dict():

if ( PHP_SAPI != 'cli' )
	header('Content-Type:text/plain;charset=UTF-8');
$r = enchant_broker_init();
debug_zval_dump($r);
$d = enchant_broker_request_dict($r, 'en-gb');
enchant_broker_free_dict($d);
debug_zval_dump($r);
echo "End.\r\n";

Result:

resource(1) of type (enchant_broker) refcount(2)
resource(1) of type (enchant_broker) refcount(2)
End.
 [2012-09-20 11:32 UTC] robert dot johnson at icap dot com
Further testing reveals that Enchant broker resource is also destroyed when the PWL dictionary resource goes out of scope.
 [2018-01-01 18:03 UTC] cmb@php.net
For some reason the broker resource is indeed freed when the dict
is freed[1].

[1] <https://github.com/php/php-src/blob/PHP-7.2.0/ext/enchant/enchant.c#L276>
 [2018-01-02 15:26 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-01-02 15:26 UTC] cmb@php.net
> For some reason the broker resource is indeed freed when the
> dict is freed

No.  zend_list_delete() only decreases the refcount here.
Actually, I'm not able to reproduce the reported behavior under
PHP-7.1, so I assume this issue had been fixed in the meantime.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC